@@ -309,7 +309,7 @@ func (d *Devbox) RunScript(cmdName string, cmdArgs []string) error {
309
309
return err
310
310
}
311
311
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 ... ), " " )
313
313
}
314
314
315
315
return nix .RunScript (d .projectDir , strings .Join (cmdWithArgs , " " ), env )
@@ -696,7 +696,7 @@ func (d *Devbox) printPackageUpdateMessage(
696
696
// 3. Append the cleaned host PATH (tradeoff between reproducibility and ease of use).
697
697
// 4. Prepend the devbox-managed nix profile path (which is needed to support devbox add inside shell--can we do without it?).
698
698
// 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 ) {
700
700
701
701
vaf , err := nix .PrintDevEnv (d .nixShellFilePath (), d .nixFlakesFilePath ())
702
702
if err != nil {
@@ -722,35 +722,32 @@ func (d *Devbox) computeNixEnv() ([]string, error) {
722
722
}
723
723
}
724
724
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
-
741
725
pluginEnv , err := plugin .Env (d .packages (), d .projectDir )
742
726
if err != nil {
743
727
return nil , err
744
728
}
745
- envPairs = append (envPairs , pluginEnv ... )
729
+ for k , v := range pluginEnv {
730
+ env [k ] = v
731
+ }
746
732
747
733
// TODO: add shell-specific vars, including:
748
734
// - NIXPKGS_ALLOW_UNFREE=1 (not needed in run because we don't expect nix calls there)
749
735
// - __ETC_PROFILE_NIX_SOURCED=1 (not needed in run because we don't expect rc files to try to load nix profiles)
750
736
// - HISTFILE (not needed in run because it's non-interactive)
751
737
// - (some of) nix.envToKeep.
752
738
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
754
751
}
755
752
756
753
// TODO savil. move to packages.go
0 commit comments