summaryrefslogtreecommitdiff
path: root/pkgs/build-support/substitute-files/substitute-all-files.nix
blob: 66cafe07c0588f1cc9208eff5e7c55edb21e4664 (about) (plain)
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
27
28
{ lib, stdenv }:

args:

stdenv.mkDerivation (
  {
    name = if args ? name then args.name else baseNameOf (toString args.src);
    builder = builtins.toFile "builder.sh" ''
      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
)