8 name = "nix-required-mounts";
9 meta.maintainers = with lib.maintainers; [ SomeoneSerge ];
11 { config, pkgs, ... }:
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" ];
23 "/supported-feature-files"
25 host = "/usr/lib/imaginary-fhs-drivers";
26 guest = "/run/opengl-driver/lib";
29 unsafeFollowSymlinks = true;
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"
41 def person_do(cmd, succeed=True):
42 cmd = shlex.quote(cmd)
43 cmd = f"su person -l -c {cmd} &>/dev/console"
46 return machine.succeed(cmd)
48 return machine.fail(cmd)
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}")