Skip to content

Commit

Permalink
Add argument for build specific environment
Browse files Browse the repository at this point in the history
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;
    ...
  }
  • Loading branch information
iteratee committed Feb 27, 2024
1 parent 0366b73 commit ccbd38a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion derivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ in
, distDir ? "dist"
, installInPlace ? false
, installEnv ? { }
, buildEnv ? { }
, noDevDependencies ? false
, extraNodeModuleSources ? [ ]
, copyPnpmStore ? true
Expand Down Expand Up @@ -68,6 +69,12 @@ in
'';

buildPhase = ''
${concatStringsSep "\n" (
mapAttrsToList
(n: v: ''export ${n}="${v}"'')
buildEnv
)}
runHook preBuild
pnpm run ${script}
Expand Down Expand Up @@ -159,6 +166,6 @@ in
};

})
(attrs // { extraNodeModuleSources = null; installEnv = null; })
(attrs // { extraNodeModuleSources = null; installEnv = null; buildEnv = null;})
);
}

0 comments on commit ccbd38a

Please sign in to comment.