about summary refs log tree commit diff
path: root/nixos/tests/envfs.nix
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2022-12-28 15:09:54 +0100
committerJörg Thalheim <joerg@thalheim.io>2022-12-28 16:03:49 +0100
commit741a0f5a7f0dc997b775cb3bc45b469ba23e4675 (patch)
treec1a89f9b79f6b0cf0be473ba5ef0131e4650ac78 /nixos/tests/envfs.nix
parent4d5535c90c817917015bf26794d29802e254cb32 (diff)
envfs: init at 1.0.0
Diffstat (limited to 'nixos/tests/envfs.nix')
-rw-r--r--nixos/tests/envfs.nix42
1 files changed, 42 insertions, 0 deletions
diff --git a/nixos/tests/envfs.nix b/nixos/tests/envfs.nix
new file mode 100644
index 0000000000000..3f9cd1edb595a
--- /dev/null
+++ b/nixos/tests/envfs.nix
@@ -0,0 +1,42 @@
+import ./make-test-python.nix ({ lib, pkgs, ... }:
+let
+  pythonShebang = pkgs.writeScript "python-shebang" ''
+    #!/usr/bin/python
+    print("OK")
+  '';
+
+  bashShebang = pkgs.writeScript "bash-shebang" ''
+    #!/usr/bin/bash
+    echo "OK"
+  '';
+in
+{
+  name = "envfs";
+  nodes.machine.services.envfs.enable = true;
+
+  testScript = ''
+    start_all()
+    machine.wait_until_succeeds("mountpoint -q /usr/bin/")
+    machine.succeed(
+        "PATH=${pkgs.coreutils}/bin /usr/bin/cp --version",
+        # check fallback paths
+        "PATH= /usr/bin/sh --version",
+        "PATH= /usr/bin/env --version",
+        "PATH= test -e /usr/bin/sh",
+        "PATH= test -e /usr/bin/env",
+        # no stat
+        "! test -e /usr/bin/cp",
+        # also picks up PATH that was set after execve
+        "! /usr/bin/hello",
+        "PATH=${pkgs.hello}/bin /usr/bin/hello",
+    )
+
+    out = machine.succeed("PATH=${pkgs.python3}/bin ${pythonShebang}")
+    print(out)
+    assert out == "OK\n"
+
+    out = machine.succeed("PATH=${pkgs.bash}/bin ${bashShebang}")
+    print(out)
+    assert out == "OK\n"
+  '';
+})