summary refs log tree commit diff
path: root/pkgs/build-support/trivial-builders.nix
diff options
context:
space:
mode:
authorRobert Helgesson <robert@rycee.net>2019-07-07 21:18:37 +0200
committerRobert Helgesson <robert@rycee.net>2019-07-13 17:03:41 +0200
commit6900a327ad5be1b8ceed10c515f6dd26d816c7ca (patch)
tree96cbd21828892016ac926888589a4842e2049bf3 /pkgs/build-support/trivial-builders.nix
parent1aaa9ba3d82890315ab7ed9a094dd4c6eb2cb7a1 (diff)
downloadnixpkgs-6900a327ad5be1b8ceed10c515f6dd26d816c7ca.tar
nixpkgs-6900a327ad5be1b8ceed10c515f6dd26d816c7ca.tar.gz
nixpkgs-6900a327ad5be1b8ceed10c515f6dd26d816c7ca.tar.bz2
nixpkgs-6900a327ad5be1b8ceed10c515f6dd26d816c7ca.tar.lz
nixpkgs-6900a327ad5be1b8ceed10c515f6dd26d816c7ca.tar.xz
nixpkgs-6900a327ad5be1b8ceed10c515f6dd26d816c7ca.tar.zst
nixpkgs-6900a327ad5be1b8ceed10c515f6dd26d816c7ca.zip
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
Diffstat (limited to 'pkgs/build-support/trivial-builders.nix')
-rw-r--r--pkgs/build-support/trivial-builders.nix10
1 files 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/<store path>/<name>
+   * # Writes contents of file to /nix/store/<store path>/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/<store path> and marks the file as