From 09f33a43896fd4baaf3eaa299e6e1e1d5944d3a2 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Mon, 6 Oct 2014 18:28:32 +0400 Subject: [PATCH] substituteAllFiles: add derivation Closes #4145 --- .../substitute-files/substitute-all-files.nix | 22 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 4 ++++ 2 files changed, 26 insertions(+) create mode 100644 pkgs/build-support/substitute-files/substitute-all-files.nix diff --git a/pkgs/build-support/substitute-files/substitute-all-files.nix b/pkgs/build-support/substitute-files/substitute-all-files.nix new file mode 100644 index 00000000000..64291901603 --- /dev/null +++ b/pkgs/build-support/substitute-files/substitute-all-files.nix @@ -0,0 +1,22 @@ +{ stdenv }: + +args: + +stdenv.mkDerivation ({ + name = if args ? name then args.name else baseNameOf (toString args.src); + builder = with stdenv.lib; builtins.toFile "builder.sh" '' + source $stdenv/setup + set -o pipefail + + eval "$preInstall" + + args= + + cd "$src" + echo -ne "${concatStringsSep "\\0" args.files}" | xargs -0 -n1 -I {} -- find {} -type f -print0 | while read -d "" line; do + mkdir -p "$out/$(dirname "$line")" + substituteAll "$line" "$out/$line" + done + ''; + preferLocalBuild = true; +} // args) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 73b2127f949..7c7863bf7ac 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -401,6 +401,10 @@ let inherit stdenv; }; + substituteAllFiles = import ../build-support/substitute-files/substitute-all-files.nix { + inherit stdenv; + }; + replaceDependency = import ../build-support/replace-dependency.nix { inherit runCommand nix lib; };