@@ -309,7 +309,7 @@ func (d *Devbox) RunScript(cmdName string, cmdArgs []string) error {
309309 return err
310310 }
311311 cmdWithArgs = []string {d .scriptPath (d .scriptFilename (arbitraryCmdFilename ))}
312- env = append ( env , fmt . Sprintf ( "DEVBOX_RUN_CMD=%s" , strings .Join (append ([]string {cmdName }, cmdArgs ... ), " " )) )
312+ env [ "DEVBOX_RUN_CMD" ] = strings .Join (append ([]string {cmdName }, cmdArgs ... ), " " )
313313 }
314314
315315 return nix .RunScript (d .projectDir , strings .Join (cmdWithArgs , " " ), env )
@@ -696,7 +696,7 @@ func (d *Devbox) printPackageUpdateMessage(
696696// 3. Append the cleaned host PATH (tradeoff between reproducibility and ease of use).
697697// 4. Prepend the devbox-managed nix profile path (which is needed to support devbox add inside shell--can we do without it?).
698698// 5. Prepend the paths of any plugins (tbd whether it's actually needed).
699- func (d * Devbox ) computeNixEnv () ([ ]string , error ) {
699+ func (d * Devbox ) computeNixEnv () (map [ string ]string , error ) {
700700
701701 vaf , err := nix .PrintDevEnv (d .nixShellFilePath (), d .nixFlakesFilePath ())
702702 if err != nil {
@@ -722,35 +722,32 @@ func (d *Devbox) computeNixEnv() ([]string, error) {
722722 }
723723 }
724724
725- // PATH handling.
726- pluginVirtenvPath := d .pluginVirtenvPath () // TODO: consider removing this; not being used?
727- nixProfilePath , err := d .profileBinPath ()
728- if err != nil {
729- return nil , err
730- }
731- nixPath := env ["PATH" ]
732- hostPath := nix .CleanEnvPath (os .Getenv ("PATH" ), os .Getenv ("NIX_PROFILES" ))
733-
734- env ["PATH" ] = fmt .Sprintf ("%s:%s:%s:%s" , pluginVirtenvPath , nixProfilePath , nixPath , hostPath )
735-
736- envPairs := []string {}
737- for k , v := range env {
738- envPairs = append (envPairs , fmt .Sprintf ("%s=%s" , k , v ))
739- }
740-
741725 pluginEnv , err := plugin .Env (d .packages (), d .projectDir )
742726 if err != nil {
743727 return nil , err
744728 }
745- envPairs = append (envPairs , pluginEnv ... )
729+ for k , v := range pluginEnv {
730+ env [k ] = v
731+ }
746732
747733 // TODO: add shell-specific vars, including:
748734 // - NIXPKGS_ALLOW_UNFREE=1 (not needed in run because we don't expect nix calls there)
749735 // - __ETC_PROFILE_NIX_SOURCED=1 (not needed in run because we don't expect rc files to try to load nix profiles)
750736 // - HISTFILE (not needed in run because it's non-interactive)
751737 // - (some of) nix.envToKeep.
752738
753- return envPairs , nil
739+ // PATH handling.
740+ pluginVirtenvPath := d .pluginVirtenvPath () // TODO: consider removing this; not being used?
741+ nixProfilePath , err := d .profileBinPath ()
742+ if err != nil {
743+ return nil , err
744+ }
745+ nixPath := env ["PATH" ]
746+ hostPath := nix .CleanEnvPath (os .Getenv ("PATH" ), os .Getenv ("NIX_PROFILES" ))
747+
748+ env ["PATH" ] = fmt .Sprintf ("%s:%s:%s:%s" , pluginVirtenvPath , nixProfilePath , nixPath , hostPath )
749+
750+ return env , nil
754751}
755752
756753// TODO savil. move to packages.go
0 commit comments