Skip to content

Commit b47c956

Browse files
authored
test: Install Nix as a CI step (#125)
1 parent 66decab commit b47c956

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v3
12-
- uses: nixbuild/nix-quick-install-action@v21
12+
- uses: nixbuild/nix-quick-install-action@v22
1313
with:
14+
# We use newer Nix for:
15+
# - https://github.com/NixOS/nix/issues/7263
16+
# - https://github.com/NixOS/nix/issues/7026
17+
nix_version: 2.14.1
1418
nix_conf: |
1519
experimental-features = nix-command flakes
1620
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}

runtest.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
set -euo pipefail
44

55
source ./test/common.sh
6+
nix --version
67

78
# The test directory must contain a 'test.sh' file that will be run in that
89
# directory.

test/common.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,18 @@ HASKELL_FLAKE=${DIR_OF_COMMON_SH}/..
1616
OVERRIDE_HASKELL_FLAKE="--override-input haskell-flake path:${HASKELL_FLAKE}"
1717
OVERRIDE_NIXPKGS="--override-input nixpkgs github:nixos/nixpkgs/bb31220cca6d044baa6dc2715b07497a2a7c4bc7"
1818

19-
# Waiting on github.com/nixbuild/nix-quick-install-action to support 2.13+
20-
# We use newer Nix for:
21-
# - https://github.com/NixOS/nix/issues/7263
22-
# - https://github.com/NixOS/nix/issues/7026
23-
nix build --no-link github:nixos/nix/2.14.1
24-
export PATH=$(nix eval --raw github:nixos/nix/2.14.1#default.outPath)/bin:$PATH
25-
echo $PATH
26-
nix --version
19+
currentver="$(nix eval --raw --expr builtins.nixVersion)"
20+
requiredver="2.14.1"
21+
if [ "$(printf '%s\n' "$requiredver" "$currentver" | sort -V | head -n1)" = "$requiredver" ];
22+
then
23+
echo
24+
else
25+
echo "!!!! Your Nix version is old ($currentver). Using newer Nix from github:nixos/nix/2.14.1"
26+
# We use newer Nix for:
27+
# - https://github.com/NixOS/nix/issues/7263
28+
# - https://github.com/NixOS/nix/issues/7026
29+
nix build --no-link github:nixos/nix/2.14.1
30+
export PATH=$(nix eval --raw github:nixos/nix/2.14.1#default.outPath)/bin:$PATH
31+
fi
2732

33+
nix --version

0 commit comments

Comments
 (0)