diff --git a/release.nix b/release.nix index b4c6904e..9b78a137 100644 --- a/release.nix +++ b/release.nix @@ -89,6 +89,7 @@ let examples.lnl = genExample ./modules/examples/lnl.nix; examples.simple = genExample ./modules/examples/simple.nix; + tests.activation-scripts = makeTest ./tests/activation-scripts.nix; tests.environment-path = makeTest ./tests/environment-path.nix; tests.launchd-setenv = makeTest ./tests/launchd-setenv.nix; tests.networking-hostname = makeTest ./tests/networking-hostname.nix; diff --git a/tests/activation-scripts.nix b/tests/activation-scripts.nix new file mode 100644 index 00000000..e7d08569 --- /dev/null +++ b/tests/activation-scripts.nix @@ -0,0 +1,27 @@ +{ config, pkgs, ... }: + +{ + system.activationScripts.preUserActivation.text = "echo hook preUserActivation"; + system.activationScripts.extraUserActivation.text = "echo hook extraUserActivation"; + system.activationScripts.postUserActivation.text = "echo hook postUserActivation"; + + system.activationScripts.preActivation.text = "echo hook preActivation"; + system.activationScripts.extraActivation.text = "echo hook extraActivation"; + system.activationScripts.postActivation.text = "echo hook postActivation"; + + test = '' + countHooks() { + awk '/echo hook / {i++ ; print i " => " $0}' "$2" | grep "$1" + } + + echo checking activation hooks in /activate-user >&2 + countHooks "1 => echo hook preUserActivation" ${config.out}/activate-user + countHooks "2 => echo hook extraUserActivation" ${config.out}/activate-user + countHooks "3 => echo hook postUserActivation" ${config.out}/activate-user + + echo checking activation hooks in /activate >&2 + countHooks "1 => echo hook preActivation" ${config.out}/activate + countHooks "2 => echo hook extraActivation" ${config.out}/activate + countHooks "3 => echo hook postActivation" ${config.out}/activate + ''; +}