Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion nixos/modules/config/shells-environment.nix
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,13 @@ in
/bin/sh
'';

system.build.setEnvironment = pkgs.writeText "set-environment"
environment.etc."set-environment".text =
''
# DO NOT EDIT -- this file has been generated automatically.

# Prevent this file from being sourced by child shells.
export __NIXOS_SET_ENVIRONMENT_DONE=1

${exportedEnvVars}

${cfg.extraInit}
Expand Down
4 changes: 3 additions & 1 deletion nixos/modules/programs/bash/bash.nix
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ in
programs.bash = {

shellInit = ''
${config.system.build.setEnvironment.text}
if [ -z "$__NIXOS_SET_ENVIRONMENT_DONE" ]; then
. /etc/set-environment
fi

${cfge.shellInit}
'';
Expand Down
4 changes: 3 additions & 1 deletion nixos/modules/programs/fish.nix
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ in
set fish_function_path ${pkgs.fish-foreign-env}/share/fish-foreign-env/functions $__fish_datadir/functions

# source the NixOS environment config
fenv source ${config.system.build.setEnvironment}
if [ -z "$__NIXOS_SET_ENVIRONMENT_DONE" ]
fenv source /etc/set-environment
end

# clear fish_function_path so that it will be correctly set when we return to $__fish_datadir/config.fish
set -e fish_function_path
Expand Down
4 changes: 3 additions & 1 deletion nixos/modules/programs/zsh/zsh.nix
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ in
if [ -n "$__ETC_ZSHENV_SOURCED" ]; then return; fi
export __ETC_ZSHENV_SOURCED=1

${config.system.build.setEnvironment.text}
if [ -z "$__NIXOS_SET_ENVIRONMENT_DONE" ]; then
. /etc/set-environment
fi

${cfge.shellInit}

Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/editors/emacs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ in {

serviceConfig = {
Type = "forking";
ExecStart = "${pkgs.bash}/bin/bash -c 'source ${config.system.build.setEnvironment}; exec ${cfg.package}/bin/emacs --daemon'";
ExecStart = "${pkgs.bash}/bin/bash -c 'source /etc/set-environment; exec ${cfg.package}/bin/emacs --daemon'";
ExecStop = "${cfg.package}/bin/emacsclient --eval (kill-emacs)";
Restart = "always";
};
Expand Down