1{ lib, ... }:
2let
3 inherit (builtins)
4 storeDir
5 ;
6 inherit (lib)
7 types
8 mkOption
9 ;
10in
11{
12 imports = [
13 {
14 options = {
15 pathInStore = mkOption { type = types.lazyAttrsOf (types.pathWith { inStore = true; }); };
16 pathNotInStore = mkOption { type = types.lazyAttrsOf (types.pathWith { inStore = false; }); };
17 anyPath = mkOption { type = types.lazyAttrsOf (types.pathWith { }); };
18 absolutePathNotInStore = mkOption {
19 type = types.lazyAttrsOf (
20 types.pathWith {
21 inStore = false;
22 absolute = true;
23 }
24 );
25 };
26
27 # This conflicts with `conflictingPathOptionType` below.
28 conflictingPathOptionType = mkOption { type = types.pathWith { absolute = true; }; };
29
30 # This doesn't make sense: the only way to have something be `inStore`
31 # is to have an absolute path.
32 impossiblePathOptionType = mkOption {
33 type = types.pathWith {
34 inStore = true;
35 absolute = false;
36 };
37 };
38 };
39 }
40 {
41 options = {
42 # This should merge cleanly with `pathNotInStore` above.
43 pathNotInStore = mkOption {
44 type = types.lazyAttrsOf (
45 types.pathWith {
46 inStore = false;
47 absolute = null;
48 }
49 );
50 };
51
52 # This conflicts with `conflictingPathOptionType` above.
53 conflictingPathOptionType = mkOption { type = types.pathWith { absolute = false; }; };
54 };
55 }
56 ];
57
58 pathInStore.ok1 = "${storeDir}/0lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv";
59 pathInStore.ok2 = "${storeDir}/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15";
60 pathInStore.ok3 = "${storeDir}/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15/bin/bash";
61 pathInStore.ok4 = "/1121rp0gvr1qya7hvy925g5kjwg66acz6sn1ra1hca09f1z5dsab"; # CA derivation
62 pathInStore.ok5 = "/1121rp0gvr1qya7hvy925g5kjwg66acz6sn1ra1hca09f1z5dsab/bin/bash"; # CA derivation
63 pathInStore.ok6 = /1121rp0gvr1qya7hvy925g5kjwg66acz6sn1ra1hca09f1z5dsab; # CA derivation, path type
64 pathInStore.bad1 = "";
65 pathInStore.bad2 = "${storeDir}";
66 pathInStore.bad3 = "${storeDir}/";
67 pathInStore.bad4 = "${storeDir}/.links"; # technically true, but not reasonable
68 pathInStore.bad5 = "/foo/bar";
69
70 pathNotInStore.ok1 = "/foo/bar";
71 pathNotInStore.ok2 = "${storeDir}"; # strange, but consistent with `pathInStore` above
72 pathNotInStore.ok3 = "${storeDir}/"; # also strange, but also consistent
73 pathNotInStore.ok4 = "";
74 pathNotInStore.ok5 = "${storeDir}/.links"; # strange, but consistent with `pathInStore` above
75 pathNotInStore.bad1 = "${storeDir}/0lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv";
76 pathNotInStore.bad2 = "${storeDir}/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15";
77 pathNotInStore.bad3 = "${storeDir}/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15/bin/bash";
78 pathNotInStore.bad4 = ./pathWith.nix;
79
80 anyPath.ok1 = "/this/is/absolute";
81 anyPath.ok2 = "./this/is/relative";
82 anyPath.bad1 = 42;
83
84 absolutePathNotInStore.ok1 = "/this/is/absolute";
85 absolutePathNotInStore.bad1 = "./this/is/relative";
86 absolutePathNotInStore.bad2 = "${storeDir}/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15";
87
88 conflictingPathOptionType = "/foo/bar";
89
90 impossiblePathOptionType = "/foo/bar";
91}