From 4af7278bc91ecb7b61d72f41c544f74271385760 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 1 Sep 2018 14:53:23 +0200 Subject: 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. --- pkgs/build-support/trivial-builders.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'pkgs/build-support/trivial-builders.nix') diff --git a/pkgs/build-support/trivial-builders.nix b/pkgs/build-support/trivial-builders.nix index f9816b2d0d7c..d2acc2679afa 100644 --- a/pkgs/build-support/trivial-builders.nix +++ b/pkgs/build-support/trivial-builders.nix @@ -145,7 +145,10 @@ rec { # entries is a list of attribute sets like { name = "name" ; path = "/nix/store/..."; } linkFarm = name: entries: runCommand name { preferLocalBuild = true; } ("mkdir -p $out; cd $out; \n" + - (lib.concatMapStrings (x: "ln -s '${x.path}' '${x.name}';\n") entries)); + (lib.concatMapStrings (x: '' + mkdir -p "$(dirname '${x.name}')" + ln -s '${x.path}' '${x.name}' + '') entries)); # Print an error message if the file with the specified name and -- cgit 1.4.1