Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildEnv: allow custom environment variables to be set #20822

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions pkgs/build-support/buildenv/default.nix
Expand Up @@ -38,12 +38,15 @@
, # Additional inputs. Handy e.g. if using makeWrapper in `postBuild`.
buildInputs ? []

# Other environment variables to set at build time.
, environment ? {}

, passthru ? {}
, meta ? {}
}:

runCommand name
rec {
(environment // rec {
inherit manifest ignoreCollisions checkCollisionContents passthru
meta pathsToLink extraPrefix postBuild buildInputs;
pkgs = builtins.toJSON (map (drv: {
Expand All @@ -54,17 +57,17 @@ runCommand name
# aren't expected to have multiple outputs.
(if drv.outputUnspecified or false
&& drv.meta.outputsToInstall or null != null
then map (outName: drv.${outName}) drv.meta.outputsToInstall
then map (outName: drv."${outName}") drv.meta.outputsToInstall
else [ drv ])
# Add any extra outputs specified by the caller of `buildEnv`.
++ lib.filter (p: p!=null)
(builtins.map (outName: drv.${outName} or null) extraOutputsToInstall);
(builtins.map (outName: drv."${outName}" or null) extraOutputsToInstall);
priority = drv.meta.priority or 5;
}) paths);
preferLocalBuild = true;
# XXX: The size is somewhat arbitrary
passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else null;
}
})
''
${perl}/bin/perl -w ${./builder.pl}
eval "$postBuild"
Expand Down