From ac825aaea5f4092b652d56694b3dfba696d7736c Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sat, 5 Apr 2025 14:39:42 +0200 Subject: [PATCH] substituteAllFiles: deprecate --- doc/release-notes/rl-2505.section.md | 2 +- .../substitute-files/substitute-all-files.nix | 45 ++++++++++--------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/doc/release-notes/rl-2505.section.md b/doc/release-notes/rl-2505.section.md index 1d9cd80d851b..774954bc3bc9 100644 --- a/doc/release-notes/rl-2505.section.md +++ b/doc/release-notes/rl-2505.section.md @@ -112,7 +112,7 @@ - All support for 32‐bit Darwin systems has been dropped. -- `substituteAll` has been deprecated in favor of `replaceVars` and will be removed in the next release. +- `substituteAll` and `substituteAllFiles` have been deprecated in favor of `replaceVars` and will be removed in the next release. - Default ICU version updated from 74 to 76 diff --git a/pkgs/build-support/substitute-files/substitute-all-files.nix b/pkgs/build-support/substitute-files/substitute-all-files.nix index 66cafe07c058..b8d1ae8a6834 100644 --- a/pkgs/build-support/substitute-files/substitute-all-files.nix +++ b/pkgs/build-support/substitute-files/substitute-all-files.nix @@ -2,27 +2,32 @@ args: -stdenv.mkDerivation ( - { - name = if args ? name then args.name else baseNameOf (toString args.src); - builder = builtins.toFile "builder.sh" '' - set -o pipefail +# TODO(@wolfgangwalther): Remove substituteAllFiles after 25.05 branch-off. +lib.warn + "substituteAllFiles is deprecated and will be removed in 25.11. Use replaceVars for each file instead." + ( + stdenv.mkDerivation ( + { + name = if args ? name then args.name else baseNameOf (toString args.src); + builder = builtins.toFile "builder.sh" '' + set -o pipefail - eval "$preInstall" + eval "$preInstall" - args= + 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 + 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 -) + eval "$postInstall" + ''; + preferLocalBuild = true; + allowSubstitutes = false; + } + // args + ) + )