add github action to keep nix up-to-date

This commit is contained in:
Jörg Thalheim 2025-05-27 10:02:27 +02:00
parent 5261181216
commit bb7675caed
2 changed files with 28 additions and 1 deletions

26
.github/workflows/update-nix.yml vendored Normal file
View file

@ -0,0 +1,26 @@
name: "Update nix"
on:
repository_dispatch:
workflow_dispatch:
schedule:
- cron: "31 2 * * *"
jobs:
update-nix-releases:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v31
- name: Update nix releases
run: |
latest_nix=$(
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/NixOS/nix/releases/latest |
grep '"tag_name":' |
sed -E 's/.*"v?([^"]+)".*/\1/'
)
sed -i -E "s/nix_version=[0-9.]+/nix_version=${latest_nix}/" ./install-nix.sh
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
title: Update nix versions
labels: dependencies

View file

@ -94,7 +94,8 @@ echo "installer options: ${installer_options[*]}"
# There is --retry-on-errors, but only newer curl versions support that
curl_retries=5
while ! curl -sS -o "$workdir/install" -v --fail -L "${INPUT_INSTALL_URL:-https://releases.nixos.org/nix/nix-2.28.3/install}"
nix_version=2.28.3
while ! curl -sS -o "$workdir/install" -v --fail -L "${INPUT_INSTALL_URL:-https://releases.nixos.org/nix/nix-${nix_version}/install}"
do
sleep 1
((curl_retries--))