diff --git a/nixos/modules/config/shells-environment.nix b/nixos/modules/config/shells-environment.nix index e3ddf9e3c5fa..cc079cdc5856 100644 --- a/nixos/modules/config/shells-environment.nix +++ b/nixos/modules/config/shells-environment.nix @@ -149,6 +149,12 @@ in system.build.binsh = pkgs.bashInteractive; + # Set session variables in the shell as well. This is usually + # unnecessary, but it allows changes to session variables to take + # effect without restarting the session (e.g. by opening a new + # terminal instead of logging out of X11). + environment.variables = config.environment.sessionVariables; + environment.etc."shells".text = '' ${concatStringsSep "\n" cfg.shells} diff --git a/nixos/tests/misc.nix b/nixos/tests/misc.nix index e33581b4d2d4..8caef146ec87 100644 --- a/nixos/tests/misc.nix +++ b/nixos/tests/misc.nix @@ -98,6 +98,10 @@ import ./make-test.nix { $machine->succeed("touch /tmp2/x"); $machine->succeed("grep '/tmp2 tmpfs' /proc/mounts"); }; + + subtest "shell-vars", sub { + $machine->succeed('[ -n "$NIX_PATH" ]'); + }; ''; }