Compare commits

..

10 Commits

Author SHA1 Message Date
167742cb88 don't insist $USER needs to be set 2023-03-01 05:51:32 +00:00
3755e30bd2 Support new Nix 2.14 profile PATH 2023-03-01 05:44:36 +00:00
b15708fdde Merge pull request #152 from zimbatm/github-access-token
add github_access_token option
2022-12-30 13:05:17 +00:00
c04fcbc179 add github_access_token option
I'm starting to see rate limit issues with GitHub Actions more
frequently so I propose to make this option more readily available.
2022-12-29 23:28:06 +01:00
a590bb1bf6 Merge pull request #150 from daiseeai/master
Don't add daemon option if no-daemon is supplied
2022-12-21 15:24:16 +00:00
d0ac6617f6 Dont add daemon option if no-daemon is supplied 2022-12-16 13:43:21 +11:00
11f4ad19be README: bump versions 2022-10-12 14:22:41 +01:00
daddc62a2e Merge pull request #144 from cachix/fix-ci
try to fix act test
2022-10-12 15:15:08 +02:00
4024cf0f9d Merge pull request #143 from ggreif/patch-1
readme: don't perpetuate old versions
2022-10-12 15:01:35 +02:00
3d1155ed72 readme: don't perpetuate old versions
(actually, `@v17` will still cause deprecation warnings, but I'll leave this for the upcoming release)
2022-10-12 14:29:44 +02:00
3 changed files with 28 additions and 17 deletions

View File

@ -33,8 +33,8 @@ jobs:
tests: tests:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2.4.0 - uses: actions/checkout@v3
- uses: cachix/install-nix-action@v15 - uses: cachix/install-nix-action@v18
with: with:
nix_path: nixpkgs=channel:nixos-unstable nix_path: nixpkgs=channel:nixos-unstable
- run: nix-build - run: nix-build
@ -52,11 +52,10 @@ jobs:
tests: tests:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2.4.0 - uses: actions/checkout@v3
- uses: cachix/install-nix-action@v15 - uses: cachix/install-nix-action@v18
with: with:
extra_nix_config: | github_access_token: ${{ secrets.GITHUB_TOKEN }}
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- run: nix build - run: nix build
- run: nix flake check - run: nix flake check
``` ```
@ -65,11 +64,15 @@ To install Nix from any commit, go to [the corresponding installer_test action](
## Inputs (specify using `with:`) ## Inputs (specify using `with:`)
- `extra_nix_config`: append to `/etc/nix/nix.conf`
- `github_access_token`: configure nix to pull from github using the given github token. This helps work around rate limit issues.
- `install_url`: specify URL to install Nix from (useful for testing non-stable releases or pinning Nix for example https://releases.nixos.org/nix/nix-2.3.7/install) - `install_url`: specify URL to install Nix from (useful for testing non-stable releases or pinning Nix for example https://releases.nixos.org/nix/nix-2.3.7/install)
- `nix_path`: set `NIX_PATH` environment variable, for example `nixpkgs=channel:nixos-unstable` - `install_options`: Additional installer flags passed to the installer script.
- `extra_nix_config`: append to `/etc/nix/nix.conf` - `nix_path`: set `NIX_PATH` environment variable, for example `nixpkgs=channel:nixos-unstable`
--- ---
@ -119,7 +122,7 @@ Otherwise, you can add any binary cache to nix.conf using
install-nix-action's own `extra_nix_config` input: install-nix-action's own `extra_nix_config` input:
```yaml ```yaml
- uses: cachix/install-nix-action@vXX - uses: cachix/install-nix-action@v18
with: with:
extra_nix_config: | extra_nix_config: |
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=

View File

@ -2,14 +2,16 @@ name: 'Install Nix'
description: 'Installs Nix on GitHub Actions for the supported platforms: Linux and macOS.' description: 'Installs Nix on GitHub Actions for the supported platforms: Linux and macOS.'
author: 'Domen Kožar' author: 'Domen Kožar'
inputs: inputs:
extra_nix_config:
description: 'Gets appended to `/etc/nix/nix.conf` if passed.'
github_access_token:
description: 'Configure nix to pull from github using the given github token.'
install_url: install_url:
description: 'Installation URL that will contain a script to install Nix.' description: 'Installation URL that will contain a script to install Nix.'
install_options: install_options:
description: 'Additional installer flags passed to the installer script.' description: 'Additional installer flags passed to the installer script.'
nix_path: nix_path:
description: 'Set NIX_PATH environment variable.' description: 'Set NIX_PATH environment variable.'
extra_nix_config:
description: 'gets appended to `/etc/nix/nix.conf` if passed.'
branding: branding:
color: 'blue' color: 'blue'
icon: 'sun' icon: 'sun'
@ -19,7 +21,8 @@ runs:
- run : ${{ github.action_path }}/install-nix.sh - run : ${{ github.action_path }}/install-nix.sh
shell: bash shell: bash
env: env:
INPUT_INSTALL_URL: ${{ inputs.install_url }}
INPUT_INSTALL_OPTIONS: ${{ inputs.install_options }}
INPUT_NIX_PATH: ${{ inputs.nix_path }}
INPUT_EXTRA_NIX_CONFIG: ${{ inputs.extra_nix_config }} INPUT_EXTRA_NIX_CONFIG: ${{ inputs.extra_nix_config }}
INPUT_GITHUB_ACCESS_TOKEN: ${{ inputs.github_access_token }}
INPUT_INSTALL_OPTIONS: ${{ inputs.install_options }}
INPUT_INSTALL_URL: ${{ inputs.install_url }}
INPUT_NIX_PATH: ${{ inputs.nix_path }}

View File

@ -20,7 +20,11 @@ add_config() {
# Set jobs to number of cores # Set jobs to number of cores
add_config "max-jobs = auto" add_config "max-jobs = auto"
# Allow binary caches for user # Allow binary caches for user
add_config "trusted-users = root $USER" add_config "trusted-users = root ${USER:-}"
# Add github access token
if [[ $INPUT_GITHUB_ACCESS_TOKEN != "" ]]; then
add_config "access-tokens" "github.com=$INPUT_GITHUB_ACCESS_TOKEN"
fi
# Append extra nix configuration if provided # Append extra nix configuration if provided
if [[ $INPUT_EXTRA_NIX_CONFIG != "" ]]; then if [[ $INPUT_EXTRA_NIX_CONFIG != "" ]]; then
add_config "$INPUT_EXTRA_NIX_CONFIG" add_config "$INPUT_EXTRA_NIX_CONFIG"
@ -37,7 +41,7 @@ installer_options=(
) )
# only use the nix-daemon settings if on darwin (which get ignored) or systemd is supported # only use the nix-daemon settings if on darwin (which get ignored) or systemd is supported
if [[ $OSTYPE =~ darwin || -e /run/systemd/system ]]; then if [[ (! $INPUT_INSTALL_OPTIONS =~ "--no-daemon") && ($OSTYPE =~ darwin || -e /run/systemd/system) ]]; then
installer_options+=( installer_options+=(
--daemon --daemon
--daemon-user-count "$(python3 -c 'import multiprocessing as mp; print(mp.cpu_count() * 2)')" --daemon-user-count "$(python3 -c 'import multiprocessing as mp; print(mp.cpu_count() * 2)')"
@ -82,7 +86,8 @@ fi
# Set paths # Set paths
echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH" echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"
echo "/nix/var/nix/profiles/per-user/$USER/profile/bin" >> "$GITHUB_PATH" # new path for nix 2.14
echo "$HOME/.nix-profile/bin" >> "$GITHUB_PATH"
if [[ $INPUT_NIX_PATH != "" ]]; then if [[ $INPUT_NIX_PATH != "" ]]; then
echo "NIX_PATH=${INPUT_NIX_PATH}" >> "$GITHUB_ENV" echo "NIX_PATH=${INPUT_NIX_PATH}" >> "$GITHUB_ENV"