core/pkgs/build-support/substitute-files/substitute-all-files.nix

30 lines
635 B
Nix
Raw Normal View History

2024-05-02 00:46:19 +00:00
{ lib, stdenv }:
args:
2024-06-30 08:12:46 +00:00
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
2024-05-02 00:46:19 +00:00
2024-06-30 08:12:46 +00:00
eval "$preInstall"
2024-05-02 00:46:19 +00:00
2024-06-30 08:12:46 +00:00
args=
2024-05-02 00:46:19 +00:00
2024-06-30 08:12:46 +00:00
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
2024-05-02 00:46:19 +00:00
2024-06-30 08:12:46 +00:00
eval "$postInstall"
'';
preferLocalBuild = true;
allowSubstitutes = false;
}
// args
)