From 3a4ab517310688c4696aa016714fc2eb48adfe00 Mon Sep 17 00:00:00 2001 From: Infinidoge Date: Mon, 22 May 2023 01:39:46 -0400 Subject: [PATCH] pkgs: add substituteSubset --- pkgs/default.nix | 2 ++ pkgs/substitute-subset.nix | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 pkgs/substitute-subset.nix diff --git a/pkgs/default.nix b/pkgs/default.nix index e577f3c..d07e6f7 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -14,4 +14,6 @@ final: prev: { sim65 = final.callPackage ./sim65.nix { }; unbted = final.callPackage ./unbted.nix { }; + + substituteSubset = final.callPackage ./substitute-subset.nix { }; } diff --git a/pkgs/substitute-subset.nix b/pkgs/substitute-subset.nix new file mode 100644 index 0000000..2edc1ee --- /dev/null +++ b/pkgs/substitute-subset.nix @@ -0,0 +1,27 @@ +{ 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= + + cp -r "$src" "$out" + + pushd "$out" + echo -ne "${lib.concatStringsSep "\\0" args.files}" | xargs -0 -n1 -I {} -- find {} -type f -print0 | while read -d "" line; do + substituteAllInPlace "$line" + done + popd + + eval "$postInstall" + ''; + preferLocalBuild = true; + allowSubstitutes = false; +} // args)