From 6900a327ad5be1b8ceed10c515f6dd26d816c7ca Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 7 Jul 2019 21:18:37 +0200 Subject: trivial-builders: support '/' in writeTextDir Before one would get the following error nix-repl> pkgs.writeTextDir "share/my-file" "foo" error: invalid character '/' in name 'share/my-file' Fixes #50347 --- pkgs/build-support/trivial-builders.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/trivial-builders.nix b/pkgs/build-support/trivial-builders.nix index 5706a98f600..0bfe14a8539 100644 --- a/pkgs/build-support/trivial-builders.nix +++ b/pkgs/build-support/trivial-builders.nix @@ -94,17 +94,21 @@ rec { /* * Writes a text file to nix store in a specific directory with no - * optional parameters available. Name passed is the destination. + * optional parameters available. * * Example: - * # Writes contents of file to /nix/store// + * # Writes contents of file to /nix/store//share/my-file * writeTextDir "share/my-file" * '' * Contents of File * ''; * */ - writeTextDir = name: text: writeTextFile {inherit name text; destination = "/${name}";}; + writeTextDir = path: text: writeTextFile { + inherit text; + name = builtins.baseNameOf path; + destination = "/${path}"; + }; /* * Writes a text file to /nix/store/ and marks the file as -- cgit 1.4.1