From ccbd38a03743195505e8fc7f800fdccd6c18d227 Mon Sep 17 00:00:00 2001 From: Kyle Butt Date: Wed, 14 Feb 2024 12:12:58 -0700 Subject: [PATCH] Add argument for build specific environment It is likely that a user may want to specify environment variables during the build phase as well as during pnpm install. Add an argument for a build specific environment. This allows the user to avoid duplicating the environment between a configure or prebuild step and installEnv, by using something like: let sharedEnv = { ... }; buildEnvOverrides = { ... }; installEnvOverrides = { ... }; in mkPnpmPackage { buildEnv = sharedEnv // buildEnvOverrides; installEnv = sharedEnv // installEnvOverrides; ... } --- derivation.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/derivation.nix b/derivation.nix index affaea8..a032422 100644 --- a/derivation.nix +++ b/derivation.nix @@ -26,6 +26,7 @@ in , distDir ? "dist" , installInPlace ? false , installEnv ? { } + , buildEnv ? { } , noDevDependencies ? false , extraNodeModuleSources ? [ ] , copyPnpmStore ? true @@ -68,6 +69,12 @@ in ''; buildPhase = '' + ${concatStringsSep "\n" ( + mapAttrsToList + (n: v: ''export ${n}="${v}"'') + buildEnv + )} + runHook preBuild pnpm run ${script} @@ -159,6 +166,6 @@ in }; }) - (attrs // { extraNodeModuleSources = null; installEnv = null; }) + (attrs // { extraNodeModuleSources = null; installEnv = null; buildEnv = null;}) ); }