aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2022-01-21 10:45:36 +1100
committerJustin Bedo <cu@cua0.org>2022-01-21 10:45:36 +1100
commite509bf390e4fdbdc31dadfe769500344739fca57 (patch)
treea99cdf2457fa2f87abf88be1908269382eae6377
parent8378b7d51381ae3328e0de48c4680c04201e1c84 (diff)
linkOutputs: rewrite to use script instead of environment variable
Previous implementation had issues when linking large numbers of outputs due to large environment variables (buildCommand). This patch reimplements linkOutputs to place the linking commands in a script rather than hold the commands in an environment variable.
-rw-r--r--default.nix24
1 files changed, 12 insertions, 12 deletions
diff --git a/default.nix b/default.nix
index 3ec0450..842f55a 100644
--- a/default.nix
+++ b/default.nix
@@ -89,12 +89,8 @@ let
def = f: defs: attrs: f (defs // attrs);
linkOutputs = x:
- with lib;
- nixpkgs.stdenvNoCC.mkDerivation {
- name = "link-outputs";
- outputs = [ "out" ] ++ attrNames x;
- nativeBuildInputs = [ pkgs.perl ];
- buildCommand =
+ let
+ cmds =
let
recurse = x:
if x ? type && x.type == "derivation" then
@@ -104,14 +100,18 @@ let
else
abort "linkOutputs: unsupported type";
link = dst: src: ''
- ln -s ${recurse src} $(perl -e 'print $ENV{"${dst}"}') ; ln -s ${
- recurse src
- } $out/${dst}
- '';
+ ln -s ${recurse src} $(perl -e 'print $ENV{"${dst}"}') ; ln -s ${recurse src} $out/${dst}
+ '';
in
''
- mkdir $out
- '' + (concatStringsSep "\n" (mapAttrsToList link x));
+ mkdir $out
+ ${lib.concatStringsSep "\n" (lib.mapAttrsToList link x)}
+ '';
+ in
+ pkgs.stdenvNoCC.mkDerivation {
+ name = "link-outputs";
+ nativeBuildInputs = [ pkgs.perl ];
+ buildCommand = "exec sh ${pkgs.writeScript "make-links" cmds}";
passthru.linkInputs = x;
};