summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorwill <will.bradshaw50@gmail.com>2024-08-31 18:27:10 +1000
committerwill <will.bradshaw50@gmail.com>2024-09-22 15:30:21 +1000
commit034c45dd0cac806b527e64c143020676e1070769 (patch)
tree68e15b7e10374383d9c2367c9d41756dd8f808a2 /tests
parentc03f85fa42d68d1056ca1740f3113b04f3addff2 (diff)
feat: use wait4path with script launchd option
addresses https://github.com/LnL7/nix-darwin/issues/1043 fix: use exec in launchd daemon config fix: dont use a script thats in the nix store fix: remove manual wait4path in linux-builder fix: remove manual wait4path in karabiner elements fix: remove manual wait4path in nix-daemon fix: remove manual wait4path in nix-optimise fix: remove manual wait4path in tailscaled fix: autossh test Revert "fix: remove manual wait4path in nix-daemon" This reverts commit 6aec084fa5d095666e81676e78f7054c83703faa. fix: remove bad exec Reapply "fix: remove manual wait4path in nix-daemon" This reverts commit c8f136ecc555f803124af471324bc6ed1163d6dd. fix: update autossh test to reflect changes in f86e6133d957becb1958da638516b0860fbd7491 fix: services-activate-system-changed-label-prefix test fix: services-buildkite-agent test fix: services-activate-system test fix: escape ampersand fix: services-lorri test fix: services-nix-optimise test fix: services-nix-gc test refactor: use script rather than command in daemon fix: use config.command for clarity style: fix indentation fix: use lib.getExe rather than directly pointing to file revert: a87fc7bbbbdb7c25c5ad6721c93990ea035affdd - mistaken refactor meant that service waited for nix store and not the relevant path
Diffstat (limited to 'tests')
-rw-r--r--tests/autossh.nix16
-rw-r--r--tests/services-activate-system-changed-label-prefix.nix2
-rw-r--r--tests/services-activate-system.nix2
-rw-r--r--tests/services-buildkite-agent.nix4
-rw-r--r--tests/services-lorri.nix25
-rw-r--r--tests/services-nix-gc.nix4
-rw-r--r--tests/services-nix-optimise.nix4
7 files changed, 37 insertions, 20 deletions
diff --git a/tests/autossh.nix b/tests/autossh.nix
index d1aacd0..5279bf9 100644
--- a/tests/autossh.nix
+++ b/tests/autossh.nix
@@ -1,17 +1,19 @@
{ config, pkgs, ... }:
{
- services.autossh.sessions = [ {
- name = "foo";
- user = "jfelice";
- extraArguments = "-i /some/key -T -N bar.eraserhead.net";
- } ];
+ services.autossh.sessions = [
+ {
+ name = "foo";
+ user = "jfelice";
+ extraArguments = "-i /some/key -T -N bar.eraserhead.net";
+ }
+ ];
test = ''
plist=${config.out}/Library/LaunchDaemons/org.nixos.autossh-foo.plist
test -f $plist
- grep '<string>exec /nix/store/.*/bin/autossh ' $plist
- grep '<string>exec.*-i /some/key ' $plist
+ grep '<string>/bin/wait4path /nix/store &amp;&amp; exec /nix/store/.*/bin/autossh ' $plist
+ grep '<string>/bin/wait4path /nix/store &amp;&amp; exec.*-i /some/key ' $plist
tr -d '\n\t ' <$plist |grep '<key>KeepAlive</key><true */>'
'';
}
diff --git a/tests/services-activate-system-changed-label-prefix.nix b/tests/services-activate-system-changed-label-prefix.nix
index 5ac9969..1ae2bcf 100644
--- a/tests/services-activate-system-changed-label-prefix.nix
+++ b/tests/services-activate-system-changed-label-prefix.nix
@@ -9,7 +9,7 @@
grep "org.nix-darwin.activate-system" ${config.out}/Library/LaunchDaemons/org.nix-darwin.activate-system.plist
echo checking activation of /run/current-system >&2
- script=$(cat ${config.out}/Library/LaunchDaemons/org.nix-darwin.activate-system.plist | awk -F'[< ]' '$3 ~ "^/nix/store/.*" {print $3}')
+ script=$(cat ${config.out}/Library/LaunchDaemons/org.nix-darwin.activate-system.plist | awk -F'[< ]' '$6 ~ "^/nix/store/.*" {print $6}')
grep "ln -sfn .* /run/current-system" "$script"
'';
}
diff --git a/tests/services-activate-system.nix b/tests/services-activate-system.nix
index 02eaf3c..c519aa8 100644
--- a/tests/services-activate-system.nix
+++ b/tests/services-activate-system.nix
@@ -8,7 +8,7 @@
grep "org.nixos.activate-system" ${config.out}/Library/LaunchDaemons/org.nixos.activate-system.plist
echo checking activation of /run/current-system >&2
- script=$(cat ${config.out}/Library/LaunchDaemons/org.nixos.activate-system.plist | awk -F'[< ]' '$3 ~ "^/nix/store/.*" {print $3}')
+ script=$(cat ${config.out}/Library/LaunchDaemons/org.nixos.activate-system.plist | awk -F'[< ]' '$6 ~ "^/nix/store/.*" {print $6}')
grep "ln -sfn .* /run/current-system" "$script"
'';
}
diff --git a/tests/services-buildkite-agent.nix b/tests/services-buildkite-agent.nix
index 557aad2..1d8d824 100644
--- a/tests/services-buildkite-agent.nix
+++ b/tests/services-buildkite-agent.nix
@@ -1,7 +1,7 @@
{ config, pkgs, ... }:
let
- buildkite-agent = pkgs.runCommand "buildkite-agent-0.0.0" {} "mkdir $out";
+ buildkite-agent = pkgs.runCommand "buildkite-agent-0.0.0" { } "mkdir $out";
tokenPath = pkgs.writeText "buildkite_token" "TEST_TOKEN";
in
@@ -20,7 +20,7 @@ in
grep "org.nixos.buildkite-agent-test" ${config.out}/Library/LaunchDaemons/org.nixos.buildkite-agent-test.plist
echo "checking creation of buildkite-agent service config" >&2
- script=$(cat ${config.out}/Library/LaunchDaemons/org.nixos.buildkite-agent-test.plist | awk -F'[< ]' '$3 ~ "^/nix/store/.*" {print $3}')
+ script=$(cat ${config.out}/Library/LaunchDaemons/org.nixos.buildkite-agent-test.plist | awk -F'[< ]' '$6 ~ "^/nix/store/.*" {print $6}')
grep "yolo=1" "$script"
grep "${tokenPath}" "$script"
diff --git a/tests/services-lorri.nix b/tests/services-lorri.nix
index 52dcc91..7d30152 100644
--- a/tests/services-lorri.nix
+++ b/tests/services-lorri.nix
@@ -1,14 +1,29 @@
-{ config, pkgs, lib, ... }:
+{
+ config,
+ pkgs,
+ lib,
+ ...
+}:
let
plistPath = "${config.out}/user/Library/LaunchAgents/org.nixos.lorri.plist";
- expectedPath = "${lib.makeBinPath [config.nix.package pkgs.git pkgs.gnutar pkgs.gzip]}";
- expectedNixPath = "${"nixpkgs="+ toString pkgs.path}";
+ expectedPath = "${lib.makeBinPath [
+ config.nix.package
+ pkgs.git
+ pkgs.gnutar
+ pkgs.gzip
+ ]}";
+ expectedNixPath = "${"nixpkgs=" + toString pkgs.path}";
in
{
services.lorri.enable = true;
test = ''
- PATH=${lib.makeBinPath [ pkgs.xcbuild pkgs.jq ]}:$PATH
+ PATH=${
+ lib.makeBinPath [
+ pkgs.xcbuild
+ pkgs.jq
+ ]
+ }:$PATH
plutil -lint ${plistPath}
plutil -convert json -o service.json ${plistPath}
@@ -21,7 +36,7 @@ in
<service.json jq -e ".ProgramArguments|length == 3"
<service.json jq -e ".ProgramArguments[0] == \"/bin/sh\""
<service.json jq -e ".ProgramArguments[1] == \"-c\""
- <service.json jq -e ".ProgramArguments[2] == \"exec ${pkgs.lorri}/bin/lorri daemon\""
+ <service.json jq -e ".ProgramArguments[2] == \"/bin/wait4path /nix/store && exec ${pkgs.lorri}/bin/lorri daemon\""
<service.json jq -e ".RunAtLoad == true"
'';
}
diff --git a/tests/services-nix-gc.nix b/tests/services-nix-gc.nix
index 4ef26b5..6d7cdef 100644
--- a/tests/services-nix-gc.nix
+++ b/tests/services-nix-gc.nix
@@ -1,7 +1,7 @@
{ config, pkgs, ... }:
let
- nix = pkgs.runCommand "nix-2.2" {} "mkdir -p $out";
+ nix = pkgs.runCommand "nix-2.2" { } "mkdir -p $out";
in
{
@@ -13,7 +13,7 @@ in
test = ''
echo checking nix-gc service in /Library/LaunchDaemons >&2
grep "<string>org.nixos.nix-gc</string>" ${config.out}/Library/LaunchDaemons/org.nixos.nix-gc.plist
- grep "<string>exec ${nix}/bin/nix-collect-garbage --delete-older-than 30d</string>" ${config.out}/Library/LaunchDaemons/org.nixos.nix-gc.plist
+ grep "<string>/bin/wait4path /nix/store &amp;&amp; exec ${nix}/bin/nix-collect-garbage --delete-older-than 30d</string>" ${config.out}/Library/LaunchDaemons/org.nixos.nix-gc.plist
grep "<key>UserName</key>" ${config.out}/Library/LaunchDaemons/org.nixos.nix-gc.plist
grep "<string>nixuser</string>" ${config.out}/Library/LaunchDaemons/org.nixos.nix-gc.plist
diff --git a/tests/services-nix-optimise.nix b/tests/services-nix-optimise.nix
index b0ecf18..4108eb0 100644
--- a/tests/services-nix-optimise.nix
+++ b/tests/services-nix-optimise.nix
@@ -1,7 +1,7 @@
{ config, pkgs, ... }:
let
- nix = pkgs.runCommand "nix-2.2" {} "mkdir -p $out";
+ nix = pkgs.runCommand "nix-2.2" { } "mkdir -p $out";
in
{
@@ -13,7 +13,7 @@ in
echo checking nix-optimise service in /Library/LaunchDaemons >&2
grep "<string>org.nixos.nix-optimise</string>" \
${config.out}/Library/LaunchDaemons/org.nixos.nix-optimise.plist
- grep "<string>/bin/wait4path ${nix} &amp;&amp; exec ${nix}/bin/nix-store --optimise</string>" \
+ grep "<string>/bin/wait4path /nix/store &amp;&amp; exec ${nix}/bin/nix-store --optimise</string>" \
${config.out}/Library/LaunchDaemons/org.nixos.nix-optimise.plist
grep "<key>UserName</key>" ${config.out}/Library/LaunchDaemons/org.nixos.nix-optimise.plist
grep "<string>nixuser</string>" ${config.out}/Library/LaunchDaemons/org.nixos.nix-optimise.plist