summary refs log tree commit diff
path: root/pkgs/build-support/substitute-files/substitute-all-files.nix
blob: 682e976dcfe52c23f6cb3f76a51b5dacf05c435b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{ lib, stdenv }:

args:

stdenv.mkDerivation ({
  name = if args ? name then args.name else baseNameOf (toString args.src);
  builder = builtins.toFile "builder.sh" ''
    source $stdenv/setup
    set -o pipefail

    eval "$preInstall"

    args=

    pushd "$src"
    echo -ne "${lib.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
    popd

    eval "$postInstall"
  '';
  preferLocalBuild = true;
  allowSubstitutes = false;
} // args)