From 1e6acabaebb2d3eb13cde9d8742aadb9480abcd7 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Sun, 30 Jun 2024 15:40:46 +0000 Subject: [PATCH 1/7] nix-channel: do not set empty nix-path when disabling channels An empty nix-path in nix.conf will disable NIX_PATH environment variable entirely, which is not necessarily implied by users who want to disable nix channels. NIX_PATH also has some usages in tools like nixos-rebuild or just as user aliases. That change is surprising and debatable, and also caused breakages in nixpkgs-review and user configs. See: - https://github.com/NixOS/nixpkgs/pull/242098/files#r1269891427 - https://github.com/Mic92/nixpkgs-review/issues/343 - https://github.com/NixOS/nix/pull/10998 Co-authored-by: oxalica --- nixos/modules/config/nix-channel.nix | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/nixos/modules/config/nix-channel.nix b/nixos/modules/config/nix-channel.nix index 6498ce6c469c..772831ab6d17 100644 --- a/nixos/modules/config/nix-channel.nix +++ b/nixos/modules/config/nix-channel.nix @@ -12,6 +12,7 @@ let mkDefault mkIf mkOption + stringAfter types ; @@ -94,10 +95,29 @@ in NIX_PATH = cfg.nixPath; }; - nix.settings.nix-path = mkIf (! cfg.channel.enable) (mkDefault ""); - systemd.tmpfiles.rules = lib.mkIf cfg.channel.enable [ ''f /root/.nix-channels - - - - ${config.system.defaultChannel} nixos\n'' ]; + + system.activationScripts.no-nix-channel = mkIf (!cfg.channel.enable) + (stringAfter [ "etc" "users" ] '' + if [ -e "/root/.nix-defexpr/channels" ]; then + echo "WARNING: /root/.nix-defexpr/channels exists, but channels have been disabled." 1>&2 + echo "Due to https://github.com/NixOS/nix/issues/9574, Nix may still use these channels when NIX_PATH is unset." 1>&2 + echo "Delete the above directory to prevent this." 1>&2 + fi + if [ -e "/nix/var/nix/profiles/per-user/root/channels" ]; then + echo "WARNING: /nix/var/nix/profiles/per-user/root/channels exists, but channels have been disabled." 1>&2 + echo "Due to https://github.com/NixOS/nix/issues/9574, Nix may still use these channels when NIX_PATH is unset." 1>&2 + echo "Delete the above directory to prevent this." 1>&2 + fi + getent passwd | while IFS=: read -r _ _ _ _ _ home _ ; do + if [ -n "$home" -a -e "$home/.nix-defexpr/channels" ]; then + echo "WARNING: $home/.nix-defexpr/channels exists, but channels have been disabled." 1>&2 + echo "Due to https://github.com/NixOS/nix/issues/9574, Nix may still use these channels when NIX_PATH is unset." 1>&2 + echo "Delete the above directory to prevent this." 1>&2 + fi + done + ''); }; } From 3fb14db08a2f7b48427bdb39372f89bcab16df39 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 16 Jul 2024 20:09:45 +0200 Subject: [PATCH 2/7] testers.shellcheck: init Needed for testing upcoming commit. --- doc/build-helpers/testers.chapter.md | 49 +++++++++++++++++++ pkgs/build-support/testers/default.nix | 2 + .../testers/shellcheck/example.sh | 3 ++ .../testers/shellcheck/tester.nix | 28 +++++++++++ .../testers/shellcheck/tests.nix | 38 ++++++++++++++ pkgs/build-support/testers/test/default.nix | 2 + 6 files changed, 122 insertions(+) create mode 100644 pkgs/build-support/testers/shellcheck/example.sh create mode 100644 pkgs/build-support/testers/shellcheck/tester.nix create mode 100644 pkgs/build-support/testers/shellcheck/tests.nix diff --git a/doc/build-helpers/testers.chapter.md b/doc/build-helpers/testers.chapter.md index 34cfc00a4953..9b2dbcd8365d 100644 --- a/doc/build-helpers/testers.chapter.md +++ b/doc/build-helpers/testers.chapter.md @@ -116,6 +116,55 @@ It has two modes: : The `lychee` package to use. +## `shellcheck` {#tester-shellcheck} + +Runs files through `shellcheck`, a static analysis tool for shell scripts. + +:::{.example #ex-shellcheck} +# Run `testers.shellcheck` + +A single script + +```nix +testers.shellcheck { + name = "shellcheck"; + src = ./script.sh; +} +``` + +Multiple files + +```nix +let + inherit (lib) fileset; +in +testers.shellcheck { + name = "shellcheck"; + src = fileset.toSource { + root = ./.; + fileset = fileset.unions [ + ./lib.sh + ./nixbsd-activate + ]; + }; +} +``` + +::: + +### Inputs {#tester-shellcheck-inputs} + +[`src` (path or string)]{#tester-shellcheck-param-src} + +: The path to the shell script(s) to check. + This can be a single file or a directory containing shell files. + All files in `src` will be checked, so you may want to provide `fileset`-based source instead of a whole directory. + +### Return value {#tester-shellcheck-return} + +A derivation that runs `shellcheck` on the given script(s). +The build will fail if `shellcheck` finds any issues. + ## `testVersion` {#tester-testVersion} Checks that the output from running a command contains the specified version string in it as a whole word. diff --git a/pkgs/build-support/testers/default.nix b/pkgs/build-support/testers/default.nix index dbf9a6d6cb05..f70b54461141 100644 --- a/pkgs/build-support/testers/default.nix +++ b/pkgs/build-support/testers/default.nix @@ -151,4 +151,6 @@ hasPkgConfigModules = callPackage ./hasPkgConfigModules/tester.nix { }; testMetaPkgConfig = callPackage ./testMetaPkgConfig/tester.nix { }; + + shellcheck = callPackage ./shellcheck/tester.nix { }; } diff --git a/pkgs/build-support/testers/shellcheck/example.sh b/pkgs/build-support/testers/shellcheck/example.sh new file mode 100644 index 000000000000..7e89bf37d3cc --- /dev/null +++ b/pkgs/build-support/testers/shellcheck/example.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +echo $@ diff --git a/pkgs/build-support/testers/shellcheck/tester.nix b/pkgs/build-support/testers/shellcheck/tester.nix new file mode 100644 index 000000000000..66f048f23095 --- /dev/null +++ b/pkgs/build-support/testers/shellcheck/tester.nix @@ -0,0 +1,28 @@ +# Dependencies (callPackage) +{ lib, stdenv, shellcheck }: + +# testers.shellcheck function +# Docs: doc/build-helpers/testers.chapter.md +# Tests: ./tests.nix +{ src }: +let + inherit (lib) fileset pathType isPath; +in +stdenv.mkDerivation { + name = "run-shellcheck"; + src = + if isPath src && pathType src == "regular" # note that for strings this would have been IFD, which we prefer to avoid + then fileset.toSource { root = dirOf src; fileset = src; } + else src; + nativeBuildInputs = [ shellcheck ]; + doCheck = true; + dontConfigure = true; + dontBuild = true; + checkPhase = '' + find . -type f -print0 \ + | xargs -0 shellcheck + ''; + installPhase = '' + touch $out + ''; +} diff --git a/pkgs/build-support/testers/shellcheck/tests.nix b/pkgs/build-support/testers/shellcheck/tests.nix new file mode 100644 index 000000000000..855aa14afead --- /dev/null +++ b/pkgs/build-support/testers/shellcheck/tests.nix @@ -0,0 +1,38 @@ +# Run: +# nix-build -A tests.testers.shellcheck + +{ lib, testers, runCommand }: +let + inherit (lib) fileset; +in +lib.recurseIntoAttrs { + + example-dir = runCommand "test-testers-shellcheck-example-dir" { + failure = testers.testBuildFailure + (testers.shellcheck { + src = fileset.toSource { + root = ./.; + fileset = fileset.unions [ + ./example.sh + ]; + }; + }); + } '' + log="$failure/testBuildFailure.log" + echo "Checking $log" + grep SC2068 "$log" + touch $out + ''; + + example-file = runCommand "test-testers-shellcheck-example-file" { + failure = testers.testBuildFailure + (testers.shellcheck { + src = ./example.sh; + }); + } '' + log="$failure/testBuildFailure.log" + echo "Checking $log" + grep SC2068 "$log" + touch $out + ''; +} diff --git a/pkgs/build-support/testers/test/default.nix b/pkgs/build-support/testers/test/default.nix index a815fe63e416..d719b0f349e4 100644 --- a/pkgs/build-support/testers/test/default.nix +++ b/pkgs/build-support/testers/test/default.nix @@ -16,6 +16,8 @@ lib.recurseIntoAttrs { hasPkgConfigModules = pkgs.callPackage ../hasPkgConfigModules/tests.nix { }; + shellcheck = pkgs.callPackage ../shellcheck/tests.nix { }; + runNixOSTest-example = pkgs-with-overlay.testers.runNixOSTest ({ lib, ... }: { name = "runNixOSTest-test"; nodes.machine = { pkgs, ... }: { From 1022da85abc8df47c7a4b7e8791ecbabd3d0770c Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 16 Jul 2024 20:25:06 +0200 Subject: [PATCH 3/7] nixos/activation-script: Add lib.sh with warn() --- .../system/activation/activation-script.nix | 2 ++ nixos/modules/system/activation/lib/lib.sh | 5 +++ nixos/modules/system/activation/lib/test.nix | 36 +++++++++++++++++++ nixos/modules/system/activation/lib/test.sh | 34 ++++++++++++++++++ nixos/tests/all-tests.nix | 1 + 5 files changed, 78 insertions(+) create mode 100644 nixos/modules/system/activation/lib/lib.sh create mode 100644 nixos/modules/system/activation/lib/test.nix create mode 100755 nixos/modules/system/activation/lib/test.sh diff --git a/nixos/modules/system/activation/activation-script.nix b/nixos/modules/system/activation/activation-script.nix index fc29aa3cb2f7..195ad31b1e56 100644 --- a/nixos/modules/system/activation/activation-script.nix +++ b/nixos/modules/system/activation/activation-script.nix @@ -33,6 +33,8 @@ let '' #!${pkgs.runtimeShell} + source ${./lib/lib.sh} + systemConfig='@out@' export PATH=/empty diff --git a/nixos/modules/system/activation/lib/lib.sh b/nixos/modules/system/activation/lib/lib.sh new file mode 100644 index 000000000000..5ecf94e81604 --- /dev/null +++ b/nixos/modules/system/activation/lib/lib.sh @@ -0,0 +1,5 @@ +# shellcheck shell=bash + +warn() { + printf "\033[1;35mwarning:\033[0m %s\n" "$*" >&2 +} diff --git a/nixos/modules/system/activation/lib/test.nix b/nixos/modules/system/activation/lib/test.nix new file mode 100644 index 000000000000..39886d305195 --- /dev/null +++ b/nixos/modules/system/activation/lib/test.nix @@ -0,0 +1,36 @@ +# Run: +# nix-build -A nixosTests.activation-lib +{ lib, stdenv, testers }: +let + inherit (lib) fileset; + + runTests = stdenv.mkDerivation { + name = "tests-activation-lib"; + src = fileset.toSource { + root = ./.; + fileset = fileset.unions [ + ./lib.sh + ./test.sh + ]; + }; + buildPhase = ":"; + doCheck = true; + postUnpack = '' + patchShebangs --build . + ''; + checkPhase = '' + ./test.sh + ''; + installPhase = '' + touch $out + ''; + }; + + runShellcheck = testers.shellcheck { + src = runTests.src; + }; + +in +lib.recurseIntoAttrs { + inherit runTests runShellcheck; +} diff --git a/nixos/modules/system/activation/lib/test.sh b/nixos/modules/system/activation/lib/test.sh new file mode 100755 index 000000000000..9b146383ad4b --- /dev/null +++ b/nixos/modules/system/activation/lib/test.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +# Run: +# ./test.sh +# or: +# nix-build -A nixosTests.activation-lib + +cd "$(dirname "${BASH_SOURCE[0]}")" +set -euo pipefail + +# report failure +onerr() { + set +e + # find failed statement + echo "call trace:" + local i=0 + while t="$(caller $i)"; do + line="${t%% *}" + file="${t##* }" + echo " $file:$line" >&2 + ((i++)) + done + # red + printf "\033[1;31mtest failed\033[0m\n" >&2 + exit 1 +} +trap onerr ERR + +source ./lib.sh + +(warn hi, this works >/dev/null) 2>&1 | grep -E $'.*warning:.* hi, this works' >/dev/null + +# green +printf "\033[1;32mok\033[0m\n" diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index d16b747bfa95..3a164edd5944 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -296,6 +296,7 @@ in { esphome = handleTest ./esphome.nix {}; etc = pkgs.callPackage ../modules/system/etc/test.nix { inherit evalMinimalConfig; }; activation = pkgs.callPackage ../modules/system/activation/test.nix { }; + activation-lib = pkgs.callPackage ../modules/system/activation/lib/test.nix { }; activation-var = runTest ./activation/var.nix; activation-nix-channel = runTest ./activation/nix-channel.nix; activation-etc-overlay-mutable = runTest ./activation/etc-overlay-mutable.nix; From 34fee8c804ed6649b18c1716f021540f616c4e68 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 16 Jul 2024 20:28:49 +0200 Subject: [PATCH 4/7] nixos/nix-channel: Highlight and tidy the warnings --- nixos/modules/config/nix-channel.nix | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/nixos/modules/config/nix-channel.nix b/nixos/modules/config/nix-channel.nix index 772831ab6d17..a6bef3f6192f 100644 --- a/nixos/modules/config/nix-channel.nix +++ b/nixos/modules/config/nix-channel.nix @@ -101,23 +101,25 @@ in system.activationScripts.no-nix-channel = mkIf (!cfg.channel.enable) (stringAfter [ "etc" "users" ] '' + explainChannelWarning=0 if [ -e "/root/.nix-defexpr/channels" ]; then - echo "WARNING: /root/.nix-defexpr/channels exists, but channels have been disabled." 1>&2 - echo "Due to https://github.com/NixOS/nix/issues/9574, Nix may still use these channels when NIX_PATH is unset." 1>&2 - echo "Delete the above directory to prevent this." 1>&2 + warn '/root/.nix-defexpr/channels exists, but channels have been disabled.' + explainChannelWarning=1 fi if [ -e "/nix/var/nix/profiles/per-user/root/channels" ]; then - echo "WARNING: /nix/var/nix/profiles/per-user/root/channels exists, but channels have been disabled." 1>&2 - echo "Due to https://github.com/NixOS/nix/issues/9574, Nix may still use these channels when NIX_PATH is unset." 1>&2 - echo "Delete the above directory to prevent this." 1>&2 + warn "/nix/var/nix/profiles/per-user/root/channels exists, but channels have been disabled." + explainChannelWarning=1 fi getent passwd | while IFS=: read -r _ _ _ _ _ home _ ; do if [ -n "$home" -a -e "$home/.nix-defexpr/channels" ]; then - echo "WARNING: $home/.nix-defexpr/channels exists, but channels have been disabled." 1>&2 - echo "Due to https://github.com/NixOS/nix/issues/9574, Nix may still use these channels when NIX_PATH is unset." 1>&2 - echo "Delete the above directory to prevent this." 1>&2 + warn "$home/.nix-defexpr/channels exists, but channels have been disabled." 1>&2 + explainChannelWarning=1 fi done + if [ $explainChannelWarning -eq 1 ]; then + echo "Due to https://github.com/NixOS/nix/issues/9574, Nix may still use these channels when NIX_PATH is unset." 1>&2 + echo "Delete the above directory or directories to prevent this." 1>&2 + fi ''); }; } From 46df92b27028a36d6150726923f8472217851d1d Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 16 Jul 2024 21:34:09 +0200 Subject: [PATCH 5/7] nixosTests.installer.switchToFlake: Adjust for workaround in #323613 --- nixos/tests/installer.nix | 52 +++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/nixos/tests/installer.nix b/nixos/tests/installer.nix index bb6ad79615fa..c026fbd8a814 100644 --- a/nixos/tests/installer.nix +++ b/nixos/tests/installer.nix @@ -350,7 +350,32 @@ let """) with subtest("Switch to flake based config"): - target.succeed("nixos-rebuild switch --flake /root/my-config#xyz") + target.succeed("nixos-rebuild switch --flake /root/my-config#xyz 2>&1 | tee activation-log >&2") + + target.succeed(""" + cat -n activation-log >&2 + """) + + target.succeed(""" + grep -F '/root/.nix-defexpr/channels exists, but channels have been disabled.' activation-log + """) + target.succeed(""" + grep -F '/nix/var/nix/profiles/per-user/root/channels exists, but channels have been disabled.' activation-log + """) + target.succeed(""" + grep -F '/root/.nix-defexpr/channels exists, but channels have been disabled.' activation-log + """) + target.succeed(""" + grep -F 'Due to https://github.com/NixOS/nix/issues/9574, Nix may still use these channels when NIX_PATH is unset.' activation-log + """) + target.succeed("rm activation-log") + + # Perform the suggested cleanups we've just seen in the log + # TODO after https://github.com/NixOS/nix/issues/9574: don't remove them yet + target.succeed(""" + rm -rf /root/.nix-defexpr/channels /nix/var/nix/profiles/per-user/root/channels /root/.nix-defexpr/channels + """) + target.shutdown() @@ -361,10 +386,19 @@ let # Note that the channel profile is still present on disk, but configured # not to be used. - with subtest("builtins.nixPath is now empty"): - target.succeed(""" - [[ "[ ]" == "$(nix-instantiate builtins.nixPath --eval --expr)" ]] - """) + # TODO after issue https://github.com/NixOS/nix/issues/9574: re-enable this assertion + # I believe what happens is + # - because of the issue, we've removed the `nix-path =` line from nix.conf + # - the "backdoor" shell is not a proper session and does not have `NIX_PATH=""` set + # - seeing no nix path settings at all, Nix loads its hardcoded default value, + # which is unfortunately non-empty + # with subtest("builtins.nixPath is now empty"): + # target.succeed(""" + # ( + # set -x; + # [[ "[ ]" == "$(nix-instantiate builtins.nixPath --eval --expr)" ]]; + # ) + # """) with subtest(" does not resolve"): target.succeed(""" @@ -378,12 +412,16 @@ let target.succeed(""" ( exec 1>&2 - rm -v /root/.nix-channels + rm -vf /root/.nix-channels rm -vrf ~/.nix-defexpr rm -vrf /nix/var/nix/profiles/per-user/root/channels* ) """) - target.succeed("nixos-rebuild switch --flake /root/my-config#xyz") + target.succeed("nixos-rebuild switch --flake /root/my-config#xyz | tee activation-log >&2") + target.succeed("cat -n activation-log >&2") + target.succeed("! grep -F '/root/.nix-defexpr/channels' activation-log") + target.succeed("! grep -F 'but channels have been disabled' activation-log") + target.succeed("! grep -F 'https://github.com/NixOS/nix/issues/9574' activation-log") target.shutdown() ''; From 3f76dcea9375379a30beb546b72ee02702b7da8f Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 16 Jul 2024 21:44:34 +0200 Subject: [PATCH 6/7] nixosTests.installer.switchToFlake: It is probably really stupid We may want to clear NIX_PATH when channels are disabled, or maybe it has to be a separate option. This is just very frustrating to me. --- nixos/tests/installer.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/tests/installer.nix b/nixos/tests/installer.nix index c026fbd8a814..3a31df775c85 100644 --- a/nixos/tests/installer.nix +++ b/nixos/tests/installer.nix @@ -392,6 +392,7 @@ let # - the "backdoor" shell is not a proper session and does not have `NIX_PATH=""` set # - seeing no nix path settings at all, Nix loads its hardcoded default value, # which is unfortunately non-empty + # Or maybe it's the new default NIX_PATH?? :( # with subtest("builtins.nixPath is now empty"): # target.succeed(""" # ( From 2d9a6864833e3cca4b05aa6bd4ef88c8813989ca Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 16 Jul 2024 22:00:16 +0200 Subject: [PATCH 7/7] nixos/nix-channel.nix: shellcheck and fix the activation check --- nixos/modules/config/nix-channel.nix | 22 +------------------ .../config/nix-channel/activation-check.sh | 21 ++++++++++++++++++ nixos/modules/config/nix-channel/test.nix | 19 ++++++++++++++++ nixos/tests/all-tests.nix | 1 + 4 files changed, 42 insertions(+), 21 deletions(-) create mode 100644 nixos/modules/config/nix-channel/activation-check.sh create mode 100644 nixos/modules/config/nix-channel/test.nix diff --git a/nixos/modules/config/nix-channel.nix b/nixos/modules/config/nix-channel.nix index a6bef3f6192f..2703a60f858f 100644 --- a/nixos/modules/config/nix-channel.nix +++ b/nixos/modules/config/nix-channel.nix @@ -100,26 +100,6 @@ in ]; system.activationScripts.no-nix-channel = mkIf (!cfg.channel.enable) - (stringAfter [ "etc" "users" ] '' - explainChannelWarning=0 - if [ -e "/root/.nix-defexpr/channels" ]; then - warn '/root/.nix-defexpr/channels exists, but channels have been disabled.' - explainChannelWarning=1 - fi - if [ -e "/nix/var/nix/profiles/per-user/root/channels" ]; then - warn "/nix/var/nix/profiles/per-user/root/channels exists, but channels have been disabled." - explainChannelWarning=1 - fi - getent passwd | while IFS=: read -r _ _ _ _ _ home _ ; do - if [ -n "$home" -a -e "$home/.nix-defexpr/channels" ]; then - warn "$home/.nix-defexpr/channels exists, but channels have been disabled." 1>&2 - explainChannelWarning=1 - fi - done - if [ $explainChannelWarning -eq 1 ]; then - echo "Due to https://github.com/NixOS/nix/issues/9574, Nix may still use these channels when NIX_PATH is unset." 1>&2 - echo "Delete the above directory or directories to prevent this." 1>&2 - fi - ''); + (stringAfter [ "etc" "users" ] (builtins.readFile ./nix-channel/activation-check.sh)); }; } diff --git a/nixos/modules/config/nix-channel/activation-check.sh b/nixos/modules/config/nix-channel/activation-check.sh new file mode 100644 index 000000000000..42b1b712d702 --- /dev/null +++ b/nixos/modules/config/nix-channel/activation-check.sh @@ -0,0 +1,21 @@ +# shellcheck shell=bash + +explainChannelWarning=0 +if [[ -e "/root/.nix-defexpr/channels" ]]; then + warn '/root/.nix-defexpr/channels exists, but channels have been disabled.' + explainChannelWarning=1 +fi +if [[ -e "/nix/var/nix/profiles/per-user/root/channels" ]]; then + warn "/nix/var/nix/profiles/per-user/root/channels exists, but channels have been disabled." + explainChannelWarning=1 +fi +while IFS=: read -r _ _ _ _ _ home _ ; do + if [[ -n "$home" && -e "$home/.nix-defexpr/channels" ]]; then + warn "$home/.nix-defexpr/channels exists, but channels have been disabled." 1>&2 + explainChannelWarning=1 + fi +done < <(getent passwd) +if [[ $explainChannelWarning -eq 1 ]]; then + echo "Due to https://github.com/NixOS/nix/issues/9574, Nix may still use these channels when NIX_PATH is unset." 1>&2 + echo "Delete the above directory or directories to prevent this." 1>&2 +fi diff --git a/nixos/modules/config/nix-channel/test.nix b/nixos/modules/config/nix-channel/test.nix new file mode 100644 index 000000000000..4b00cf9db3c4 --- /dev/null +++ b/nixos/modules/config/nix-channel/test.nix @@ -0,0 +1,19 @@ +# Run: +# nix-build -A nixosTests.nix-channel +{ lib, testers }: +let + inherit (lib) fileset; + + runShellcheck = testers.shellcheck { + src = fileset.toSource { + root = ./.; + fileset = fileset.unions [ + ./activation-check.sh + ]; + }; + }; + +in +lib.recurseIntoAttrs { + inherit runShellcheck; +} diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 3a164edd5944..61596fb8708b 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -610,6 +610,7 @@ in { nbd = handleTest ./nbd.nix {}; ncdns = handleTest ./ncdns.nix {}; ndppd = handleTest ./ndppd.nix {}; + nix-channel = pkgs.callPackage ../modules/config/nix-channel/test.nix { }; nebula = handleTest ./nebula.nix {}; netbird = handleTest ./netbird.nix {}; nimdow = handleTest ./nimdow.nix {};