mirror of
https://github.com/cachix/install-nix-action.git
synced 2024-11-27 19:03:57 +00:00
Merge pull request #45 from zimbatm/extra-nix-config
add extra_nix_config options
This commit is contained in:
commit
9dc00124fc
5 changed files with 46 additions and 8 deletions
17
.github/workflows/test.yml
vendored
17
.github/workflows/test.yml
vendored
|
@ -52,3 +52,20 @@ jobs:
|
|||
nix_path: nixpkgs=channel:nixos-20.03
|
||||
- run: test $NIX_PATH == "nixpkgs=channel:nixos-20.03"
|
||||
- run: nix-build test.nix
|
||||
|
||||
extra-nix-config:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: yarn install --frozen-lockfile
|
||||
- run: yarn build
|
||||
- name: Install Nix
|
||||
uses: ./
|
||||
with:
|
||||
extra_nix_config: |
|
||||
sandbox = relaxed
|
||||
- run: cat /etc/nix/nix.conf
|
||||
- run: nix-build test.nix --arg noChroot true
|
||||
|
|
|
@ -35,6 +35,7 @@ with developers.
|
|||
- `nix_path`: set `NIX_PATH` environment variable (if set `skip_adding_nixpkgs_channel` will be implicitly enabled)
|
||||
|
||||
- `skip_adding_nixpkgs_channel`: set to `true` to skip adding nixpkgs-unstable channel (and save ~5s for each job build)
|
||||
- `extra_nix_config`: gets appended to `/etc/nix/nix.conf` if passed.
|
||||
|
||||
---
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ inputs:
|
|||
description: 'Set NIX_PATH environment variable. If set "skip_adding_nixpkgs_channel" will be implicitly enabled'
|
||||
skip_adding_nixpkgs_channel:
|
||||
description: 'Skip adding nixpkgs-unstable channel'
|
||||
extra_nix_config:
|
||||
description: 'gets appended to `/etc/nix/nix.conf` if passed.'
|
||||
branding:
|
||||
color: 'blue'
|
||||
icon: 'sun'
|
||||
|
|
|
@ -1,20 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Configure Nix
|
||||
add_config() {
|
||||
echo "$1" | sudo tee -a /tmp/nix.conf >/dev/null
|
||||
}
|
||||
# Set jobs to number of cores
|
||||
sudo sh -c 'echo max-jobs = auto >> /tmp/nix.conf'
|
||||
add_config "max-jobs = auto"
|
||||
# Allow binary caches for runner user
|
||||
sudo sh -c 'echo trusted-users = root runner >> /tmp/nix.conf'
|
||||
add_config "trusted-users = root runner"
|
||||
# Append extra nix configuration if provided
|
||||
if [[ $INPUT_EXTRA_NIX_CONFIG != "" ]]; then
|
||||
add_config "$INPUT_EXTRA_NIX_CONFIG"
|
||||
fi
|
||||
|
||||
# Nix installer flags
|
||||
installer_options=(
|
||||
--daemon
|
||||
--daemon-user-count 4
|
||||
--darwin-use-unencrypted-nix-store-volume
|
||||
--nix-extra-conf-file /tmp/nix.conf
|
||||
)
|
||||
|
||||
if [[ $INPUT_SKIP_ADDING_NIXPKGS_CHANNEL = "true" || $INPUT_NIX_PATH != "" ]]; then
|
||||
extra_cmd=--no-channel-add
|
||||
installer_options+=(--no-channel-add)
|
||||
else
|
||||
extra_cmd=
|
||||
INPUT_NIX_PATH="/nix/var/nix/profiles/per-user/root/channels"
|
||||
fi
|
||||
|
||||
sh <(curl --retry 5 --retry-connrefused -L ${INPUT_INSTALL_URL:-https://nixos.org/nix/install}) \
|
||||
--daemon --daemon-user-count 4 --nix-extra-conf-file /tmp/nix.conf --darwin-use-unencrypted-nix-store-volume $extra_cmd
|
||||
sh <(curl --retry 5 --retry-connrefused -L "${INPUT_INSTALL_URL:-https://nixos.org/nix/install}") \
|
||||
"${installer_options[@]}"
|
||||
|
||||
if [[ $OSTYPE =~ darwin ]]; then
|
||||
# Disable spotlight indexing of /nix to speed up performance
|
||||
|
|
5
test.nix
5
test.nix
|
@ -2,12 +2,15 @@
|
|||
{ size ? 1 # MB
|
||||
, num ? 10 # count
|
||||
, currentTime ? builtins.currentTime
|
||||
, noChroot ? false
|
||||
}:
|
||||
|
||||
with import <nixpkgs> {};
|
||||
|
||||
let
|
||||
drv = i: runCommand "${toString currentTime}-${toString i}" {} ''
|
||||
drv = i: runCommand "${toString currentTime}-${toString i}" {
|
||||
__noChroot = noChroot;
|
||||
} ''
|
||||
dd if=/dev/zero of=$out bs=${toString size}MB count=1
|
||||
'';
|
||||
in writeText "empty-${toString num}-${toString size}MB" ''
|
||||
|
|
Loading…
Reference in a new issue