Skip to content

Commit 23efeda

Browse files
committed
refactor(gh-actions): Use the our own install-nix action
1 parent 0ef60fd commit 23efeda

File tree

3 files changed

+32
-43
lines changed

3 files changed

+32
-43
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ on:
1010
default: false
1111
required: false
1212
secrets:
13+
CACHIX_AUTH_TOKEN:
14+
description: 'Cachix auth token'
15+
required: true
16+
CACHIX_ACTIVATE_TOKEN:
17+
description: 'Cachix activate token'
18+
required: false
1319
NIX_GITHUB_TOKEN:
1420
description: GitHub token to add as access-token in nix.conf
1521
required: false
@@ -181,22 +187,13 @@ jobs:
181187
- uses: actions/checkout@v4
182188

183189
- name: Install Nix
184-
uses: cachix/install-nix-action@V27
185-
186-
- name: Configure Nix
187-
shell: bash
188-
run: |
189-
mkdir -p $HOME/.config/nix
190-
{
191-
echo "${{ inputs.nix-github-token != '' && format('access-tokens = github.com={0}', inputs.nix-github-token) || '' }}
192-
accept-flake-config = true"
193-
} > $HOME/.config/nix/nix.conf
194-
195-
- uses: cachix/cachix-action@v15
190+
uses: metacraft-labs/nixos-modules/.github/install-nix@main
196191
with:
197-
name: ${{ vars.CACHIX_CACHE }}
198-
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
199-
extraPullNames: ${{ vars.EXTRA_CACHIX_CACHES }}
192+
cachix-cache: ${{ vars.CACHIX_CACHE }}
193+
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
194+
trusted-public-keys: ${{ vars.TRUSTED_PUBLIC_KEYS }}
195+
substituters: ${{ vars.SUBSTITUTERS }}
196+
nix-github-token: ${{ secrets.NIX_GITHUB_TOKEN }}
200197

201198
- name: Build ${{ matrix.name }}
202199
run: |
@@ -231,12 +228,6 @@ jobs:
231228
&& contains(needs.*.result, 'failure')
232229
|| contains(needs.*.result, 'cancelled')
233230
234-
- uses: cachix/cachix-action@v15
235-
if: inputs.do_deploy
236-
with:
237-
name: ${{ vars.CACHIX_CACHE }}
238-
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
239-
240231
- name: Deploy
241232
if: inputs.do_deploy
242233
env:

.github/workflows/update-flake-lock.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
NIX_GITHUB_TOKEN:
88
description: GitHub token to add as access-token in nix.conf
99
required: false
10+
CACHIX_AUTH_TOKEN:
11+
description: 'Cachix auth token'
12+
required: true
1013
CREATE_PR_APP_ID:
1114
description: ID of the GitHub App used for opening pull requests.
1215
required: true
@@ -29,17 +32,13 @@ jobs:
2932
- uses: actions/checkout@v4
3033

3134
- name: Install Nix
32-
uses: cachix/install-nix-action@v27
33-
if: ${{ runner.environment == 'github-hosted' }}
34-
35-
- name: Configure Nix
36-
shell: bash
37-
run: |
38-
mkdir -p $HOME/.config/nix
39-
cat << EOF > "$HOME/.config/nix/nix.conf"
40-
${{ secrets.NIX_GITHUB_TOKEN != '' && format('access-tokens = github.com={0}', secrets.NIX_GITHUB_TOKEN) || '' }}
41-
allow-import-from-derivation = true
42-
EOF
35+
uses: metacraft-labs/nixos-modules/.github/install-nix@main
36+
with:
37+
nix-github-token: ${{ secrets.NIX_GITHUB_TOKEN }}
38+
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
39+
cachix-cache: ${{ vars.CACHIX_CACHE }}
40+
trusted-public-keys: ${{ vars.TRUSTED_PUBLIC_KEYS }}
41+
substituters: ${{ vars.SUBSTITUTERS }}
4342

4443
- name: Run `nix flake update`
4544
id: update-lockfile

.github/workflows/update-flake-packages.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
NIX_GITHUB_TOKEN:
88
description: GitHub token to add as access-token in nix.conf
99
required: false
10+
CACHIX_AUTH_TOKEN:
11+
description: 'Cachix auth token'
12+
required: true
1013
CREATE_PR_APP_ID:
1114
description: ID of the GitHub App used for opening pull requests.
1215
required: true
@@ -29,17 +32,13 @@ jobs:
2932
uses: actions/checkout@v4
3033

3134
- name: Install Nix
32-
uses: cachix/install-nix-action@v27
33-
if: ${{ runner.environment == 'github-hosted' }}
34-
35-
- name: Configure Nix
36-
shell: bash
37-
run: |
38-
mkdir -p $HOME/.config/nix
39-
cat << EOF > "$HOME/.config/nix/nix.conf"
40-
${{ secrets.NIX_GITHUB_TOKEN != '' && format('access-tokens = github.com={0}', secrets.NIX_GITHUB_TOKEN) || '' }}
41-
allow-import-from-derivation = true
42-
EOF
35+
uses: metacraft-labs/nixos-modules/.github/install-nix@main
36+
with:
37+
nix-github-token: ${{ secrets.NIX_GITHUB_TOKEN }}
38+
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
39+
cachix-cache: ${{ vars.CACHIX_CACHE }}
40+
trusted-public-keys: ${{ vars.TRUSTED_PUBLIC_KEYS }}
41+
substituters: ${{ vars.SUBSTITUTERS }}
4342

4443
- uses: tibdex/[email protected]
4544
id: generate-token

0 commit comments

Comments
 (0)