summary refs log tree commit diff
path: root/pkgs/top-level/all-packages.nix
diff options
context:
space:
mode:
authorMarc Weber <marco-oweber@gmx.de>2008-10-26 17:44:44 +0000
committerMarc Weber <marco-oweber@gmx.de>2008-10-26 17:44:44 +0000
commita08ed61bba0784051cf3c18d45f8386ce406fb94 (patch)
tree48558b24124f338fc9f87dac6664d16b7b750503 /pkgs/top-level/all-packages.nix
parenta9b19788fb574871bd27054e77b361f7f1413319 (diff)
downloadnixpkgs-a08ed61bba0784051cf3c18d45f8386ce406fb94.tar
nixpkgs-a08ed61bba0784051cf3c18d45f8386ce406fb94.tar.gz
nixpkgs-a08ed61bba0784051cf3c18d45f8386ce406fb94.tar.bz2
nixpkgs-a08ed61bba0784051cf3c18d45f8386ce406fb94.tar.lz
nixpkgs-a08ed61bba0784051cf3c18d45f8386ce406fb94.tar.xz
nixpkgs-a08ed61bba0784051cf3c18d45f8386ce406fb94.tar.zst
nixpkgs-a08ed61bba0784051cf3c18d45f8386ce406fb94.zip
added writeTextFile superseding all the other writeText writeScript(Bin) functions
svn path=/nixpkgs/trunk/; revision=13120
Diffstat (limited to 'pkgs/top-level/all-packages.nix')
-rw-r--r--pkgs/top-level/all-packages.nix22
1 files changed, 15 insertions, 7 deletions
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index b4b7b2de011..8afb645f8b6 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -431,17 +431,25 @@ let
     inherit name buildCommand;
   } // env);
 
-  # Write a plain text file to the Nix store.  (The advantage over
-  # plain sources is that `text' can refer to the output paths of
-  # derivations, e.g., "... ${somePkg}/bin/foo ...".
-  writeText = name: text: runCommand name {inherit text;} "echo -n \"$text\" > $out";
+  symlinkJoin = name: paths: runCommand name {inherit paths;} "mkdir -p $out; for i in $paths; do ${xorg.lndir}/bin/lndir $i $out; done";
 
+  # single text file derivation
+  writeTextFile = { name, # the name of the derivation
+                    text,
+                    executable ? false, # run chmod +x ?
+                    destination ? ""    # relative path appended to $out eg "/bin/foo"
+                  } :
+    runCommand name {inherit text executable; } ''
+      n=$out${destination}
+      mkdir -p "$(dirname "$n")"
+      echo -n "$text" > "$n"
+      [ -n "$executable"] && chmod +x "$n"
+      '';
+  # the following write* functions are depreceated. You should use writeTextFile instead
+  writeText = name: text: runCommand name {inherit text;} "echo -n \"$text\" > $out";
   writeScript = name: text: runCommand name {inherit text;} "echo -n \"$text\" > $out; chmod +x $out";
-
   writeScriptBin = name: text: runCommand name {inherit text;} "mkdir -p \$out/bin; echo -n \"\$text\" > \$out/bin/\$name ; chmod +x \$out/bin/\$name";
 
-  symlinkJoin = name: paths: runCommand name {inherit paths;} "mkdir -p $out; for i in $paths; do ${xorg.lndir}/bin/lndir $i $out; done";
-
   # entries is a list of attribute sets like { name = "name" ; path = "/nix/store/..."; }
   linkFarm = name: entries: runCommand name {} ("mkdir -p $out; cd $out; \n" +
     (lib.concatMapStrings (x: "ln -s '${x.path}' '${x.name}';\n") entries));