lol

nixos/documentation: Allow the inclusion of a nixpkgs/modules directory

+20 -2
+1
ci/eval/default.nix
··· 31 31 "doc" 32 32 "lib" 33 33 "maintainers" 34 + "modules" 34 35 "nixos" 35 36 "pkgs" 36 37 ".version"
+1
nixos/lib/eval-cacheable-options.nix
··· 49 49 version = release; 50 50 revision = "release-${release}"; 51 51 prefix = modulesPath; 52 + extraSources = [ (dirOf nixosPath) ]; 52 53 }; 53 54 in 54 55 docs.optionsNix
+18 -2
nixos/modules/misc/documentation.nix
··· 116 116 && (t == "directory" -> baseNameOf n != "tests") 117 117 && (t == "file" -> hasSuffix ".nix" n) 118 118 ); 119 + prefixRegex = "^" + lib.strings.escapeRegex (toString pkgs.path) + "($|/(modules|nixos)($|/.*))"; 120 + filteredModules = builtins.path { 121 + name = "source"; 122 + inherit (pkgs) path; 123 + filter = 124 + n: t: 125 + builtins.match prefixRegex n != null 126 + && cleanSourceFilter n t 127 + && (t == "directory" -> baseNameOf n != "tests") 128 + && (t == "file" -> hasSuffix ".nix" n); 129 + }; 119 130 in 120 131 pkgs.runCommand "lazy-options.json" 121 - { 132 + rec { 122 133 libPath = filter (pkgs.path + "/lib"); 123 134 pkgsLibPath = filter (pkgs.path + "/pkgs/pkgs-lib"); 124 - nixosPath = filter (pkgs.path + "/nixos"); 135 + nixosPath = filteredModules + "/nixos"; 125 136 NIX_ABORT_ON_WARN = warningsAreErrors; 126 137 modules = 127 138 "[ " 128 139 + concatMapStringsSep " " (p: ''"${removePrefix "${modulesPath}/" (toString p)}"'') docModules.lazy 129 140 + " ]"; 130 141 passAsFile = [ "modules" ]; 142 + disallowedReferences = [ 143 + filteredModules 144 + libPath 145 + pkgsLibPath 146 + ]; 131 147 } 132 148 '' 133 149 export NIX_STORE_DIR=$TMPDIR/store