vuls: init at 0.27.0
[NixPkgs.git] / nixos / tests / nix-required-mounts / default.nix
blob60f894ce0bcc6194c61dbadc3a3e6e52051e0b2e
1 { pkgs, ... }:
3 let
4   inherit (pkgs) lib;
5 in
8   name = "nix-required-mounts";
9   meta.maintainers = with lib.maintainers; [ SomeoneSerge ];
10   nodes.machine =
11     { config, pkgs, ... }:
12     {
13       virtualisation.writableStore = true;
14       system.extraDependencies = [ (pkgs.runCommand "deps" { } "mkdir $out").inputDerivation ];
15       nix.nixPath = [ "nixpkgs=${../../..}" ];
16       nix.settings.substituters = lib.mkForce [ ];
17       nix.settings.system-features = [ "supported-feature" ];
18       nix.settings.experimental-features = [ "nix-command" ];
19       programs.nix-required-mounts.enable = true;
20       programs.nix-required-mounts.allowedPatterns.supported-feature = {
21         onFeatures = [ "supported-feature" ];
22         paths = [
23           "/supported-feature-files"
24           {
25             host = "/usr/lib/imaginary-fhs-drivers";
26             guest = "/run/opengl-driver/lib";
27           }
28         ];
29         unsafeFollowSymlinks = true;
30       };
31       users.users.person.isNormalUser = true;
32       systemd.tmpfiles.rules = [
33         "d /supported-feature-files 0755 person users -"
34         "f /usr/lib/libcuda.so 0444 root root - fakeContent"
35         "L /usr/lib/imaginary-fhs-drivers/libcuda.so 0444 root root - /usr/lib/libcuda.so"
36       ];
37     };
38   testScript = ''
39     import shlex
41     def person_do(cmd, succeed=True):
42         cmd = shlex.quote(cmd)
43         cmd = f"su person -l -c {cmd} &>/dev/console"
45         if succeed:
46             return machine.succeed(cmd)
47         else:
48             return machine.fail(cmd)
50     start_all()
52     person_do("nix-build ${./ensure-path-not-present.nix} --argstr feature supported-feature")
53     person_do("nix-build ${./test-require-feature.nix} --argstr feature supported-feature")
54     person_do("nix-build ${./test-require-feature.nix} --argstr feature unsupported-feature", succeed=False)
55     person_do("nix-build ${./test-structured-attrs.nix} --argstr feature supported-feature")
56     person_do("nix-build ${./test-structured-attrs-empty.nix}")
57   '';