Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
d56f3ce9be | |||
3db69e0239 | |||
76f9967600 | |||
7a6ac48c9d | |||
31bbb1e1e8 | |||
9489b6bd0b | |||
ac899278cf | |||
c5e83e525e | |||
5315c85e43 | |||
d045d9f5d8 | |||
46187b354d | |||
802bde54e0 | |||
21a5164e12 | |||
732b0240d2 | |||
06a240d7b6 | |||
1b5d414ec3 | |||
b72fecc86e | |||
ef6c38c42b |
14
.github/workflows/test.yml
vendored
14
.github/workflows/test.yml
vendored
@ -109,3 +109,17 @@ jobs:
|
|||||||
nix_path: nixpkgs=channel:nixos-21.05
|
nix_path: nixpkgs=channel:nixos-21.05
|
||||||
install_url: https://releases.nixos.org/nix/nix-2.3.5/install
|
install_url: https://releases.nixos.org/nix/nix-2.3.5/install
|
||||||
- run: nix-build test.nix
|
- run: nix-build test.nix
|
||||||
|
|
||||||
|
act-support:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2.4.0
|
||||||
|
- uses: actions/setup-go@v2.1.4
|
||||||
|
with:
|
||||||
|
go-version: '^1.16'
|
||||||
|
- run: go install github.com/nektos/act@master
|
||||||
|
- run: docker pull ghcr.io/catthehacker/ubuntu:js-20.04
|
||||||
|
- run: ~/go/bin/act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:js-20.04 push -j simple-build
|
12
README.md
12
README.md
@ -18,7 +18,7 @@ or [pin nixpkgs yourself](https://nix.dev/reference/pinning-nixpkgs.html)
|
|||||||
- Allows specifying extra Nix configration options via `extra_nix_config`
|
- Allows specifying extra Nix configration options via `extra_nix_config`
|
||||||
- Allows specifying `$NIX_PATH` and channels via `nix_path`
|
- Allows specifying `$NIX_PATH` and channels via `nix_path`
|
||||||
- Share `/nix/store` between builds using [cachix-action](https://github.com/cachix/cachix-action) for simple binary cache setup to speed up your builds and share binaries with your team
|
- Share `/nix/store` between builds using [cachix-action](https://github.com/cachix/cachix-action) for simple binary cache setup to speed up your builds and share binaries with your team
|
||||||
- Enables `flakes` and `nix-command` experimental features by default (to disable, set ``experimental-features` via `extra_nix_config`)
|
- Enables `flakes` and `nix-command` experimental features by default (to disable, set ``experimental-features`` via ``extra_nix_config``)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -33,8 +33,8 @@ jobs:
|
|||||||
tests:
|
tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2.3.4
|
- uses: actions/checkout@v2.4.0
|
||||||
- uses: cachix/install-nix-action@v14.1
|
- uses: cachix/install-nix-action@v15
|
||||||
with:
|
with:
|
||||||
nix_path: nixpkgs=channel:nixos-unstable
|
nix_path: nixpkgs=channel:nixos-unstable
|
||||||
- run: nix-build
|
- run: nix-build
|
||||||
@ -52,11 +52,9 @@ jobs:
|
|||||||
tests:
|
tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2.3.4
|
- uses: actions/checkout@v2.4.0
|
||||||
- uses: cachix/install-nix-action@v14.1
|
- uses: cachix/install-nix-action@v15
|
||||||
with:
|
with:
|
||||||
install_url: https://nixos-nix-install-tests.cachix.org/serve/vij683ly7sl95nnhb67bdjjfabclr85m/install
|
|
||||||
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
|
|
||||||
extra_nix_config: |
|
extra_nix_config: |
|
||||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||||
- run: nix build
|
- run: nix build
|
||||||
|
@ -6,9 +6,13 @@ if type -p nix &>/dev/null ; then
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Create a temporary workdir
|
||||||
|
workdir=$(mktemp -d)
|
||||||
|
trap 'rm -rf "$workdir"' EXIT
|
||||||
|
|
||||||
# Configure Nix
|
# Configure Nix
|
||||||
add_config() {
|
add_config() {
|
||||||
echo "$1" | tee -a /tmp/nix.conf >/dev/null
|
echo "$1" | tee -a "$workdir/nix.conf" >/dev/null
|
||||||
}
|
}
|
||||||
# Set jobs to number of cores
|
# Set jobs to number of cores
|
||||||
add_config "max-jobs = auto"
|
add_config "max-jobs = auto"
|
||||||
@ -18,7 +22,7 @@ add_config "trusted-users = root $USER"
|
|||||||
if [[ $INPUT_EXTRA_NIX_CONFIG != "" ]]; then
|
if [[ $INPUT_EXTRA_NIX_CONFIG != "" ]]; then
|
||||||
add_config "$INPUT_EXTRA_NIX_CONFIG"
|
add_config "$INPUT_EXTRA_NIX_CONFIG"
|
||||||
fi
|
fi
|
||||||
if [[ ! $INPUT_EXTRA_NIX_CONFIG =~ "experimental-features" ]]; then
|
if [[ ! $INPUT_EXTRA_NIX_CONFIG =~ "experimental-features" ]]; then
|
||||||
add_config "experimental-features = nix-command flakes"
|
add_config "experimental-features = nix-command flakes"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -26,36 +30,43 @@ fi
|
|||||||
installer_options=(
|
installer_options=(
|
||||||
--no-channel-add
|
--no-channel-add
|
||||||
--darwin-use-unencrypted-nix-store-volume
|
--darwin-use-unencrypted-nix-store-volume
|
||||||
--nix-extra-conf-file /tmp/nix.conf
|
--nix-extra-conf-file "$workdir/nix.conf"
|
||||||
)
|
)
|
||||||
|
|
||||||
# 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 [[ $OSTYPE =~ darwin || -e /run/systemd/system ]]; then
|
||||||
installer_options+=(
|
installer_options+=(
|
||||||
--daemon
|
--daemon
|
||||||
--daemon-user-count `python -c 'import multiprocessing as mp; print(mp.cpu_count() * 2)'`
|
--daemon-user-count "$(python -c 'import multiprocessing as mp; print(mp.cpu_count() * 2)')"
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
# "fix" the following error when running nix*
|
# "fix" the following error when running nix*
|
||||||
# error: the group 'nixbld' specified in 'build-users-group' does not exist
|
# error: the group 'nixbld' specified in 'build-users-group' does not exist
|
||||||
add_config "build-users-group ="
|
add_config "build-users-group ="
|
||||||
|
mkdir -m 0755 /etc/nix
|
||||||
|
cp $workdir/nix.conf /etc/nix/nix.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $INPUT_INSTALL_OPTIONS != "" ]]; then
|
if [[ $INPUT_INSTALL_OPTIONS != "" ]]; then
|
||||||
IFS=' ' read -r -a extra_installer_options <<< $INPUT_INSTALL_OPTIONS
|
IFS=' ' read -r -a extra_installer_options <<< "$INPUT_INSTALL_OPTIONS"
|
||||||
installer_options=("${extra_installer_options[@]}" "${installer_options[@]}")
|
installer_options=("${extra_installer_options[@]}" "${installer_options[@]}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "installer options: ${installer_options[@]}"
|
echo "installer options: ${installer_options[*]}"
|
||||||
|
|
||||||
# There is --retry-on-errors, but only newer curl versions support that
|
# There is --retry-on-errors, but only newer curl versions support that
|
||||||
until curl -o /tmp/install -v --fail --retry 5 --retry-connrefused -L "${INPUT_INSTALL_URL:-https://nixos.org/nix/install}"
|
curl_retries=5
|
||||||
|
while ! curl -o "$workdir/install" -v --fail -L "${INPUT_INSTALL_URL:-https://nixos.org/nix/install}"
|
||||||
do
|
do
|
||||||
sleep 1
|
sleep 1
|
||||||
|
((curl_retries--))
|
||||||
|
if [[ $curl_retries -le 0 ]]; then
|
||||||
|
echo "curl retries failed" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
chmod +x /tmp/install
|
sh "$workdir/install" "${installer_options[@]}"
|
||||||
sh /tmp/install "${installer_options[@]}"
|
|
||||||
|
|
||||||
if [[ $OSTYPE =~ darwin ]]; then
|
if [[ $OSTYPE =~ darwin ]]; then
|
||||||
# macOS needs certificates hints
|
# macOS needs certificates hints
|
||||||
|
Reference in New Issue
Block a user