From b398d00903af1eca6b4e298225e85ecd118a80dd Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Wed, 10 Mar 2021 19:43:17 +0100 Subject: [PATCH] trivial-builders: merge passAsFile with env in runCommand' Previously it was awkward to use the runCommand-variants with passAsFile as a double definition of passAsFile would potentially break runCommand: passAsFile would overwrite the previous definition, defeating the purpose of setting it in runCommand in the first place. This is now fixed by concatenating the [ "buildCommand" ] list with one the one from env, if present. Adjust buildEnv where passAsFile = null; was passed in some cases, breaking evaluation since it'd evaluate to [ "buildCommand" ] ++ null. --- pkgs/build-support/buildenv/default.nix | 2 +- pkgs/build-support/trivial-builders.nix | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/buildenv/default.nix b/pkgs/build-support/buildenv/default.nix index 5fafc36273a..c2186cf6bfa 100644 --- a/pkgs/build-support/buildenv/default.nix +++ b/pkgs/build-support/buildenv/default.nix @@ -74,7 +74,7 @@ runCommand name preferLocalBuild = true; allowSubstitutes = false; # XXX: The size is somewhat arbitrary - passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else null; + passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else [ ]; } '' ${buildPackages.perl}/bin/perl -w ${builder} diff --git a/pkgs/build-support/trivial-builders.nix b/pkgs/build-support/trivial-builders.nix index eab5366e183..8759a67f4ea 100644 --- a/pkgs/build-support/trivial-builders.nix +++ b/pkgs/build-support/trivial-builders.nix @@ -6,13 +6,14 @@ let stdenv.mkDerivation ({ name = lib.strings.sanitizeDerivationName name; inherit buildCommand; - passAsFile = [ "buildCommand" ]; + passAsFile = [ "buildCommand" ] + ++ (env.passAsFile or []); } // (lib.optionalAttrs runLocal { preferLocalBuild = true; allowSubstitutes = false; }) - // env); + // builtins.removeAttrs env [ "passAsFile" ]); in