Skip to content

Commit

Permalink
refactor(gh-actions): Use bash commands instead of extra_nix_config
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinNikov authored and PetarKirov committed Aug 4, 2024
1 parent f7541c2 commit 79b2672
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 16 deletions.
17 changes: 8 additions & 9 deletions .github/install-nix/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,19 @@ runs:
- name: Install Nix
uses: cachix/install-nix-action@v27
if: ${{ runner.environment == 'github-hosted' }}
with:
extra_nix_config: |
${{ inputs.nix-github-token != '' && format('access-tokens = github.com={0}', inputs.nix-github-token) || '' }}
accept-flake-config = true
allow-import-from-derivation = true
substituters = https://cache.nixos.org ${{inputs.substituters}}
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= ${{inputs.trusted-public-keys}}
netrc-file = $HOME/.config/nix/netrc

- name: Configure Nix
if: ${{ runner.environment == 'github-hosted' }}
shell: bash
run: |
mkdir -p $HOME/.config/nix
{
echo "machine ${{inputs.cachix-cache}}.cachix.org password ${{inputs.cachix-auth-token}}"
} >> $HOME/.config/nix/netrc
{
echo "${{ inputs.nix-github-token != '' && format('access-tokens = github.com={0}', inputs.nix-github-token) || '' }}
accept-flake-config = true
allow-import-from-derivation = true
substituters = https://cache.nixos.org ${{inputs.substituters}}
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= ${{inputs.trusted-public-keys}}
netrc-file = $HOME/.config/nix/netrc"
} > $HOME/.config/nix/nix.conf
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,15 @@ jobs:

- name: Install Nix
uses: cachix/install-nix-action@V27
with:
extra_nix_config: accept-flake-config = true

- name: Configure Nix
shell: bash
run: |
mkdir -p $HOME/.config/nix
{
echo "${{ inputs.nix-github-token != '' && format('access-tokens = github.com={0}', inputs.nix-github-token) || '' }}
accept-flake-config = true"
} > $HOME/.config/nix/nix.conf
- uses: cachix/cachix-action@v15
with:
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/update-flake-lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: "Update Nix Flake lockfile"
on:
# Allow this workflow to be reused by other workflows:
workflow_call:
secrets:
nix-github-token:
description: GitHub token to add as access-token in nix.conf
required: false

# Allow this workflow to be triggered manually:
workflow_dispatch:
Expand All @@ -21,8 +25,16 @@ jobs:
- name: Install Nix
uses: cachix/install-nix-action@v27
if: ${{ runner.environment == 'github-hosted' }}
with:
extra_nix_config: accept-flake-config = true

- name: Configure Nix
shell: bash
run: |
mkdir -p $HOME/.config/nix
{
echo "${{ secrets.nix-github-token != '' && format('access-tokens = github.com={0}', secrets.nix-github-token) || '' }}
accept-flake-config = true"
} > $HOME/.config/nix/nix.conf
- name: Run `nix flake update`
id: update-lockfile
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/update-flake-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: "Update Flake Packages ❄️"
on:
# Allow this workflow to be reused by other workflows:
workflow_call:
secrets:
nix-github-token:
description: GitHub token to add as access-token in nix.conf
required: false

# Allow this workflow to be triggered manually:
workflow_dispatch:
Expand All @@ -21,10 +25,16 @@ jobs:
- name: Install Nix
uses: cachix/install-nix-action@v27
if: ${{ runner.environment == 'github-hosted' }}
with:
extra_nix_config: |

- name: Configure Nix
shell: bash
run: |
mkdir -p $HOME/.config/nix
{
echo "${{ secrets.nix-github-token != '' && format('access-tokens = github.com={0}', secrets.nix-github-token) || '' }}
accept-flake-config = true
allow-import-from-derivation = true
allow-import-from-derivation = true"
} > $HOME/.config/nix/nix.conf
- uses: tibdex/[email protected]
id: generate-token
Expand Down

0 comments on commit 79b2672

Please sign in to comment.