Skip to content

Commit 79b2672

Browse files
MartinNikovPetarKirov
authored andcommitted
refactor(gh-actions): Use bash commands instead of extra_nix_config
This commit is squashed version of these: * bbcd2cc * https://github.com/metacraft-labs/nixos-modules/pull/128/commits
1 parent f7541c2 commit 79b2672

File tree

4 files changed

+44
-16
lines changed

4 files changed

+44
-16
lines changed

.github/install-nix/action.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,19 @@ runs:
2727
- name: Install Nix
2828
uses: cachix/install-nix-action@v27
2929
if: ${{ runner.environment == 'github-hosted' }}
30-
with:
31-
extra_nix_config: |
32-
${{ inputs.nix-github-token != '' && format('access-tokens = github.com={0}', inputs.nix-github-token) || '' }}
33-
accept-flake-config = true
34-
allow-import-from-derivation = true
35-
substituters = https://cache.nixos.org ${{inputs.substituters}}
36-
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= ${{inputs.trusted-public-keys}}
37-
netrc-file = $HOME/.config/nix/netrc
3830

3931
- name: Configure Nix
40-
if: ${{ runner.environment == 'github-hosted' }}
4132
shell: bash
4233
run: |
4334
mkdir -p $HOME/.config/nix
4435
{
4536
echo "machine ${{inputs.cachix-cache}}.cachix.org password ${{inputs.cachix-auth-token}}"
4637
} >> $HOME/.config/nix/netrc
38+
{
39+
echo "${{ inputs.nix-github-token != '' && format('access-tokens = github.com={0}', inputs.nix-github-token) || '' }}
40+
accept-flake-config = true
41+
allow-import-from-derivation = true
42+
substituters = https://cache.nixos.org ${{inputs.substituters}}
43+
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= ${{inputs.trusted-public-keys}}
44+
netrc-file = $HOME/.config/nix/netrc"
45+
} > $HOME/.config/nix/nix.conf

.github/workflows/ci.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,15 @@ jobs:
182182

183183
- name: Install Nix
184184
uses: cachix/install-nix-action@V27
185-
with:
186-
extra_nix_config: accept-flake-config = true
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
187194
188195
- uses: cachix/cachix-action@v15
189196
with:

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ name: "Update Nix Flake lockfile"
33
on:
44
# Allow this workflow to be reused by other workflows:
55
workflow_call:
6+
secrets:
7+
nix-github-token:
8+
description: GitHub token to add as access-token in nix.conf
9+
required: false
610

711
# Allow this workflow to be triggered manually:
812
workflow_dispatch:
@@ -21,8 +25,16 @@ jobs:
2125
- name: Install Nix
2226
uses: cachix/install-nix-action@v27
2327
if: ${{ runner.environment == 'github-hosted' }}
24-
with:
25-
extra_nix_config: accept-flake-config = true
28+
29+
- name: Configure Nix
30+
shell: bash
31+
run: |
32+
mkdir -p $HOME/.config/nix
33+
{
34+
echo "${{ secrets.nix-github-token != '' && format('access-tokens = github.com={0}', secrets.nix-github-token) || '' }}
35+
accept-flake-config = true"
36+
} > $HOME/.config/nix/nix.conf
37+
2638
2739
- name: Run `nix flake update`
2840
id: update-lockfile

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ name: "Update Flake Packages ❄️"
33
on:
44
# Allow this workflow to be reused by other workflows:
55
workflow_call:
6+
secrets:
7+
nix-github-token:
8+
description: GitHub token to add as access-token in nix.conf
9+
required: false
610

711
# Allow this workflow to be triggered manually:
812
workflow_dispatch:
@@ -21,10 +25,16 @@ jobs:
2125
- name: Install Nix
2226
uses: cachix/install-nix-action@v27
2327
if: ${{ runner.environment == 'github-hosted' }}
24-
with:
25-
extra_nix_config: |
28+
29+
- name: Configure Nix
30+
shell: bash
31+
run: |
32+
mkdir -p $HOME/.config/nix
33+
{
34+
echo "${{ secrets.nix-github-token != '' && format('access-tokens = github.com={0}', secrets.nix-github-token) || '' }}
2635
accept-flake-config = true
27-
allow-import-from-derivation = true
36+
allow-import-from-derivation = true"
37+
} > $HOME/.config/nix/nix.conf
2838
2939
- uses: tibdex/[email protected]
3040
id: generate-token

0 commit comments

Comments
 (0)