workflows: use cachix consistently (#435294)

+5 -3
.github/workflows/build.yml
···
- uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16
with:
-
# This cache is for the nixpkgs repo checks and should not be trusted or used elsewhere.
-
name: nixpkgs-ci
-
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
+
# The nixpkgs-ci cache should not be trusted or used outside of Nixpkgs and its forks' CI.
+
name: ${{ vars.CACHIX_NAME || 'nixpkgs-ci' }}
+
extraPullNames: nixpkgs-ci
+
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
+
pushFilter: '(-source$|-nixpkgs-tarball-)'
- run: nix-env --install -f pinned -A nix-build-uncached
+5 -3
.github/workflows/check.yml
···
- uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16
with:
-
# This cache is for the nixpkgs repo checks and should not be trusted or used elsewhere.
-
name: nixpkgs-ci
-
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
+
# The nixpkgs-ci cache should not be trusted or used outside of Nixpkgs and its forks' CI.
+
name: ${{ vars.CACHIX_NAME || 'nixpkgs-ci' }}
+
extraPullNames: nixpkgs-ci
+
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
+
pushFilter: -source$
- name: Build codeowners validator
run: nix-build trusted/ci --arg nixpkgs ./pinned -A codeownersValidator
+10
.github/workflows/eval.yml
···
default: false
type: boolean
secrets:
+
CACHIX_AUTH_TOKEN:
+
required: true
OWNER_APP_PRIVATE_KEY:
required: false
···
- name: Install Nix
uses: cachix/install-nix-action@fc6e360bedc9ee72d75e701397f0bb30dce77568 # v31
+
+
- uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16
+
with:
+
# The nixpkgs-ci cache should not be trusted or used outside of Nixpkgs and its forks' CI.
+
name: ${{ vars.CACHIX_NAME || 'nixpkgs-ci' }}
+
extraPullNames: nixpkgs-ci
+
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
+
pushFilter: '(-source|-single-chunk)$'
- name: Evaluate the ${{ matrix.system }} output paths for all derivation attributes
env:
+23
.github/workflows/lint.yml
···
targetSha:
required: true
type: string
+
secrets:
+
CACHIX_AUTH_TOKEN:
+
required: true
permissions: {}
···
- uses: cachix/install-nix-action@fc6e360bedc9ee72d75e701397f0bb30dce77568 # v31
+
# TODO: Figure out how to best enable caching for the treefmt job. Cachix won't work well,
+
# because the cache would be invalidated on every commit - treefmt checks every file.
+
# Maybe we can cache treefmt's eval-cache somehow.
+
- name: Check that files are formatted
run: |
# Note that it's fine to run this on untrusted code because:
···
- uses: cachix/install-nix-action@fc6e360bedc9ee72d75e701397f0bb30dce77568 # v31
+
- uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16
+
with:
+
# The nixpkgs-ci cache should not be trusted or used outside of Nixpkgs and its forks' CI.
+
name: ${{ vars.CACHIX_NAME || 'nixpkgs-ci' }}
+
extraPullNames: nixpkgs-ci
+
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
+
pushFilter: -source$
+
- name: Parse all nix files
run: |
# Tests multiple versions at once, let's make sure all of them run, so keep-going.
···
target-as-trusted: true
- uses: cachix/install-nix-action@fc6e360bedc9ee72d75e701397f0bb30dce77568 # v31
+
+
- uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16
+
with:
+
# The nixpkgs-ci cache should not be trusted or used outside of Nixpkgs and its forks' CI.
+
name: ${{ vars.CACHIX_NAME || 'nixpkgs-ci' }}
+
extraPullNames: nixpkgs-ci
+
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
+
pushFilter: -source$
- name: Running nixpkgs-vet
env:
+2
.github/workflows/merge-group.yml
···
lint:
name: Lint
uses: ./.github/workflows/lint.yml
+
secrets:
+
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
with:
mergedSha: ${{ github.event.merge_group.head_sha }}
targetSha: ${{ github.event.merge_group.base_sha }}
+3
.github/workflows/pr.yml
···
name: Lint
needs: [prepare]
uses: ./.github/workflows/lint.yml
+
secrets:
+
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
with:
mergedSha: ${{ needs.prepare.outputs.mergedSha }}
targetSha: ${{ needs.prepare.outputs.targetSha }}
···
# compare
statuses: write
secrets:
+
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
OWNER_APP_PRIVATE_KEY: ${{ secrets.OWNER_APP_PRIVATE_KEY }}
with:
mergedSha: ${{ needs.prepare.outputs.mergedSha }}
+2
.github/workflows/push.yml
···
issues: write
pull-requests: write
statuses: write
+
secrets:
+
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
with:
mergedSha: ${{ github.sha }}
systems: ${{ needs.prepare.outputs.systems }}
+10 -4
ci/nixpkgs-vet.nix
···
with lib.fileset;
path:
toSource {
-
fileset = (gitTracked path);
+
fileset = difference (gitTracked path) (unions [
+
(path + /.github)
+
(path + /ci)
+
]);
root = path;
};
+
+
filteredBase = filtered base;
+
filteredHead = filtered head;
in
runCommand "nixpkgs-vet"
{
···
''
export NIX_STATE_DIR=$(mktemp -d)
-
nixpkgs-vet --base ${filtered base} ${filtered head}
+
nixpkgs-vet --base ${filteredBase} ${filteredHead}
# TODO: Upstream into nixpkgs-vet, see:
# https://github.com/NixOS/nixpkgs-vet/issues/164
-
badFiles=$(find ${filtered head}/pkgs -type f -name '*.nix' -print | xargs grep -l '^[^#]*<nixpkgs/' || true)
+
badFiles=$(find ${filteredHead}/pkgs -type f -name '*.nix' -print | xargs grep -l '^[^#]*<nixpkgs/' || true)
if [[ -n $badFiles ]]; then
echo "Nixpkgs is not allowed to use <nixpkgs> to refer to itself."
echo "The offending files:"
···
# TODO: Upstream into nixpkgs-vet, see:
# https://github.com/NixOS/nixpkgs-vet/issues/166
-
conflictingPaths=$(find ${filtered head} | awk '{ print $1 " " tolower($1) }' | sort -k2 | uniq -D -f 1 | cut -d ' ' -f 1)
+
conflictingPaths=$(find ${filteredHead} | awk '{ print $1 " " tolower($1) }' | sort -k2 | uniq -D -f 1 | cut -d ' ' -f 1)
if [[ -n $conflictingPaths ]]; then
echo "Files in nixpkgs must not vary only by case."
echo "The offending paths:"