File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 44 cfg = config . nixos-shell ;
55 home = builtins . getEnv "HOME" ;
66 mkVMDefault = lib . mkOverride 900 ;
7+ foreignVM = options . virtualisation . host . pkgs . isDefined && config . virtualisation . host . pkgs . stdenv . hostPlatform != pkgs . stdenv . hostPlatform ;
78in {
89 config =
910 let
9596 cfg . mounts . extraMounts ) ;
9697
9798 # avoid leaking incompatible host binaries into the VM
98- system . activationScripts . shadow-nix-profile = lib . mkIf ( options . virtualisation . host . pkgs . isDefined && config . virtualisation . host . pkgs . stdenv . hostPlatform != pkgs . stdenv . hostPlatform ) ( lib . stringAfter [ "specialfs" "users" "groups" ] ''
99+ system . activationScripts . shadow-nix-profile = lib . mkIf foreignVM ( lib . stringAfter [ "specialfs" "users" "groups" ] ''
99100 mkdir -p ${ lib . escapeShellArg home } /.nix-profile/
100101 mount --bind ${ config . system . path } ${ lib . escapeShellArg home } /.nix-profile/
101102 '' ) ;
117118
118119 ${ lib . optionalString ( pwd != "" ) "cd '${ pwd } ' 2>/dev/null" }
119120 ${ lib . optionalString ( term != "" ) "export TERM='${ term } '" }
120- ${ lib . optionalString ( path != "" ) "export PATH=\" ${ path } :$PATH\" " }
121+ ${ lib . optionalString ( cfg . inheritPath && path != "" ) "export PATH=\" ${ path } :$PATH\" " }
121122 '' ;
122123 } ;
123124
Original file line number Diff line number Diff line change 66 ] ;
77
88 options . nixos-shell = with lib ; {
9+ inheritPath = mkOption {
10+ type = types . bool ;
11+ default = options . virtualisation . host . pkgs . isDefined && config . virtualisation . host . pkgs . stdenv . hostPlatform == pkgs . stdenv . hostPlatform ;
12+ description = "Whether to inherit the user's PATH." ;
13+ } ;
14+
915 mounts = let
1016 cache = mkOption {
1117 type = types . enum [ "none" "loose" "fscache" "mmap" ] ;
You can’t perform that action at this time.
0 commit comments