git.iko.soy/typeable/nixpkgs
on master help sign in
lib: ensure directories of linkFarm links exist (#45628)

There's no reason `linkFarm` can't be used for symlinks in subdirectories, except that currently it doesn't ensure the directory of the link exists. This backwards-compatible change expands the utility of the function.

commit4af7278bc91ecb7b61d72f41c544f74271385760 authorAlyssa Ross <hi@alyssa.is> dateSat 1 Sep 2018, 14:53 (8 years ago) parent173e48d
1 file changed+4−1
pkgs/build-support/trivial-builders.nix+4−1
pkgs/build-support/trivial-builders.nix+4−1
@@ -145,7 +145,10 @@ rec {
145145 # entries is a list of attribute sets like { name = "name" ; path = "/nix/store/..."; }
146146 linkFarm = name: entries: runCommand name { preferLocalBuild = true; }
147147 ("mkdir -p $out; cd $out; \n" +
148− (lib.concatMapStrings (x: "ln -s '${x.path}' '${x.name}';\n") entries));
148+ (lib.concatMapStrings (x: ''
149+ mkdir -p "$(dirname '${x.name}')"
150+ ln -s '${x.path}' '${x.name}'
151+ '') entries));
149152
150153
151154 # Print an error message if the file with the specified name and