Bump nixpkgs #1531
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Bump nixpkgs | |
on: | |
schedule: | |
- cron: '47 6 * * *' | |
workflow_dispatch: | |
repository_dispatch: | |
types: [nixpkgs-update] | |
permissions: | |
contents: write | |
actions: write | |
concurrency: | |
group: nyx-main-bump | |
cancel-in-progress: true | |
jobs: | |
bump: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Nix | |
uses: cachix/install-nix-action@v26 | |
with: | |
extra_nix_config: | | |
accept-flake-config = true | |
system-features = big-parallel gccarch-x86-64-v3 | |
install_url: https://releases.nixos.org/nix/nix-2.20.5/install | |
- uses: actions/checkout@v4 | |
- name: Update nixpkgs flake | |
run: nix flake lock --update-input nixpkgs || exit 1; git diff --exit-code flake.lock && exit 1 || exit 0 | |
continue-on-error: true | |
id: bump | |
- name: Commit nixpkgs bump | |
id: commit | |
if: steps.bump.outcome == 'success' | |
run: | | |
set -e | |
git config --global user.name 'Chaotic Github Actions' | |
git config --global user.email 'actions@chaotic.cx' | |
git add flake.lock | |
git commit -m "nixpkgs: bump to $(date +%Y%m%d)" | |
git push | |
COMMIT_HASH="$(git rev-parse HEAD)" | |
echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_OUTPUT | |
# Trigger build.yml and make sure no new commits were pushed in the meantime | |
- name: Trigger build.yml workflow | |
if: (success() && steps.bump.outcome == 'success') | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
try { | |
var comparison = await github.rest.repos.compareCommits({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
base: process.env.COMMIT_HASH, | |
head: process.env.REF_NAME, | |
}); | |
if (comparison.data.status != 'identical') { | |
core.setFailed('Skipping build because unknown commits were pushed'); | |
return; | |
} | |
github.rest.actions.createWorkflowDispatch({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
workflow_id: 'build.yml', | |
ref: process.env.REF_NAME, | |
inputs: { | |
"nixpkgs-bump": true | |
} | |
}); | |
} catch (error) { | |
core.setFailed(error); | |
} | |
env: | |
COMMIT_HASH: ${{ steps.commit.outputs.COMMIT_HASH }} | |
REF_NAME: ${{ github.ref_name }} |