From ae8cb8c65e33cb2e28d61d6dcfbfeba0e098362b Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Tue, 12 Aug 2025 07:26:57 +0800 Subject: [PATCH] buildEnv: reference attributes from finalAttrs --- pkgs/build-support/buildenv/default.nix | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pkgs/build-support/buildenv/default.nix b/pkgs/build-support/buildenv/default.nix index 3f02d95fa538..3e794d492cc6 100644 --- a/pkgs/build-support/buildenv/default.nix +++ b/pkgs/build-support/buildenv/default.nix @@ -93,9 +93,12 @@ lib.makeOverridable ( [ drv ] ) # Add any extra outputs specified by the caller of `buildEnv`. - ++ lib.filter (p: p != null) (map (outName: drv.${outName} or null) extraOutputsToInstall); + ++ lib.filter (p: p != null) ( + map (outName: drv.${outName} or null) finalAttrs.extraOutputsToInstall + ); priority = drv.meta.priority or lib.meta.defaultPriority; - }) paths; + # Silently use the original `paths` if `passthru.paths` is missing. + }) finalAttrs.passthru.paths or paths; pathsForClosure = lib.pipe chosenOutputs [ (map (p: p.paths)) @@ -103,13 +106,14 @@ lib.makeOverridable ( (lib.remove null) ]; in - rec { + { inherit + extraOutputsToInstall manifest ignoreCollisions checkCollisionContents ignoreSingleFileOutputs - passthru + includeClosures meta pathsToLink extraPrefix @@ -119,19 +123,27 @@ lib.makeOverridable ( ; pathsToLinkJSON = builtins.toJSON pathsToLink; pkgs = builtins.toJSON chosenOutputs; - extraPathsFrom = lib.optionalString includeClosures (writeClosure pathsForClosure); + extraPathsFrom = lib.optionalString finalAttrs.includeClosures (writeClosure pathsForClosure); preferLocalBuild = true; allowSubstitutes = false; passAsFile = [ "buildCommand" ] # XXX: The size is somewhat arbitrary - ++ lib.optional (lib.stringLength pkgs >= 128 * 1024) "pkgs"; + ++ lib.optional (lib.stringLength finalAttrs.pkgs >= 128 * 1024) "pkgs"; buildCommand = '' ${buildPackages.perl}/bin/perl -w ${builder} eval "$postBuild" ''; + + passthru = { + # Attributes to override from passthru + inherit + paths + ; + } + // passthru; }; # Function argument set pattern doesn't have an ellipsis