Merge pull request #45 from zimbatm/extra-nix-config
add extra_nix_config options
This commit is contained in:
commit
9dc00124fc
17
.github/workflows/test.yml
vendored
17
.github/workflows/test.yml
vendored
@ -52,3 +52,20 @@ jobs:
|
|||||||
nix_path: nixpkgs=channel:nixos-20.03
|
nix_path: nixpkgs=channel:nixos-20.03
|
||||||
- run: test $NIX_PATH == "nixpkgs=channel:nixos-20.03"
|
- run: test $NIX_PATH == "nixpkgs=channel:nixos-20.03"
|
||||||
- run: nix-build test.nix
|
- 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)
|
- `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)
|
- `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'
|
description: 'Set NIX_PATH environment variable. If set "skip_adding_nixpkgs_channel" will be implicitly enabled'
|
||||||
skip_adding_nixpkgs_channel:
|
skip_adding_nixpkgs_channel:
|
||||||
description: 'Skip adding nixpkgs-unstable channel'
|
description: 'Skip adding nixpkgs-unstable channel'
|
||||||
|
extra_nix_config:
|
||||||
|
description: 'gets appended to `/etc/nix/nix.conf` if passed.'
|
||||||
branding:
|
branding:
|
||||||
color: 'blue'
|
color: 'blue'
|
||||||
icon: 'sun'
|
icon: 'sun'
|
||||||
|
@ -1,20 +1,35 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Configure Nix
|
||||||
|
add_config() {
|
||||||
|
echo "$1" | sudo tee -a /tmp/nix.conf >/dev/null
|
||||||
|
}
|
||||||
# Set jobs to number of cores
|
# 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
|
# 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
|
if [[ $INPUT_SKIP_ADDING_NIXPKGS_CHANNEL = "true" || $INPUT_NIX_PATH != "" ]]; then
|
||||||
extra_cmd=--no-channel-add
|
installer_options+=(--no-channel-add)
|
||||||
else
|
else
|
||||||
extra_cmd=
|
|
||||||
INPUT_NIX_PATH="/nix/var/nix/profiles/per-user/root/channels"
|
INPUT_NIX_PATH="/nix/var/nix/profiles/per-user/root/channels"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sh <(curl --retry 5 --retry-connrefused -L ${INPUT_INSTALL_URL:-https://nixos.org/nix/install}) \
|
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
|
"${installer_options[@]}"
|
||||||
|
|
||||||
if [[ $OSTYPE =~ darwin ]]; then
|
if [[ $OSTYPE =~ darwin ]]; then
|
||||||
# Disable spotlight indexing of /nix to speed up performance
|
# Disable spotlight indexing of /nix to speed up performance
|
||||||
|
5
test.nix
5
test.nix
@ -2,12 +2,15 @@
|
|||||||
{ size ? 1 # MB
|
{ size ? 1 # MB
|
||||||
, num ? 10 # count
|
, num ? 10 # count
|
||||||
, currentTime ? builtins.currentTime
|
, currentTime ? builtins.currentTime
|
||||||
|
, noChroot ? false
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with import <nixpkgs> {};
|
with import <nixpkgs> {};
|
||||||
|
|
||||||
let
|
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
|
dd if=/dev/zero of=$out bs=${toString size}MB count=1
|
||||||
'';
|
'';
|
||||||
in writeText "empty-${toString num}-${toString size}MB" ''
|
in writeText "empty-${toString num}-${toString size}MB" ''
|
||||||
|
Loading…
Reference in New Issue
Block a user