From 1511e72b75b49cdeeee68def0c203f997d01bafa Mon Sep 17 00:00:00 2001 From: pennae Date: Sat, 18 Dec 2021 20:10:18 +0100 Subject: [PATCH] nixos/documentation: avoid copying nixpkgs subpaths the docs build should work well even when called from a git checkout of nixpkgs, but should avoid as much work as possible in all cases. if pkgs.path is already a store path we can avoid copying parts of it into the docs build sandbox by wrapping pkgs.path in builtins.storePath --- nixos/modules/misc/documentation.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nixos/modules/misc/documentation.nix b/nixos/modules/misc/documentation.nix index 4451f3026f8..e908a4ae02d 100644 --- a/nixos/modules/misc/documentation.nix +++ b/nixos/modules/misc/documentation.nix @@ -67,11 +67,15 @@ let (t == "directory" -> baseNameOf n != "tests") && (t == "file" -> hasSuffix ".nix" n) ); + pull = dir: + if isStorePath pkgs.path + then "${builtins.storePath pkgs.path}/${dir}" + else filter "${toString pkgs.path}/${dir}"; in pkgs.runCommand "lazy-options.json" { - libPath = filter "${toString pkgs.path}/lib"; - pkgsLibPath = filter "${toString pkgs.path}/pkgs/pkgs-lib"; - nixosPath = filter "${toString pkgs.path}/nixos"; + libPath = pull "lib"; + pkgsLibPath = pull "pkgs/pkgs-lib"; + nixosPath = pull "nixos"; modules = map (p: ''"${removePrefix "${modulesPath}/" (toString p)}"'') docModules.lazy; } '' export NIX_STORE_DIR=$TMPDIR/store