diff --git a/modules/default.nix b/modules/default.nix
index 0b163c7d2..78fc5e7f1 100644
--- a/modules/default.nix
+++ b/modules/default.nix
@@ -8,6 +8,7 @@ with lib;
let
modules = [
+ ./shell-session-vars.nix
./home-environment.nix
./manual.nix
./misc/gtk.nix
diff --git a/modules/home-environment.nix b/modules/home-environment.nix
index 6596a1162..0c54153fb 100644
--- a/modules/home-environment.nix
+++ b/modules/home-environment.nix
@@ -164,13 +164,13 @@ in
};
home.sessionVariableSetter = mkOption {
- default = "bash";
- type = types.enum [ "pam" "bash" ];
+ default = "shell";
+ type = types.enum [ "pam" "shell" "bash" ];
example = "pam";
description = ''
Identifies the module that should set the session variables.
- If "bash" is set then config.bash.enable
+ If "shell" is set then config.bash.enable
must also be enabled.
If "pam" is set then PAM must be used to set the system
diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix
index a8004580d..aaa027284 100644
--- a/modules/programs/bash.nix
+++ b/modules/programs/bash.nix
@@ -110,9 +110,6 @@ in
histControlStr = concatStringsSep ":" cfg.historyControl;
histIgnoreStr = concatStringsSep ":" cfg.historyIgnore;
- envVarsStr = concatStringsSep "\n" (
- mapAttrsToList export config.home.sessionVariables
- );
in mkIf cfg.enable {
home.file.".bash_profile".text = ''
# -*- mode: sh -*-
@@ -127,8 +124,9 @@ in
home.file.".profile".text = ''
# -*- mode: sh -*-
- ${optionalString (config.home.sessionVariableSetter == "bash")
- envVarsStr}
+ ${optionalString (config.home.sessionVariableSetter == "shell"
+ || config.home.sessionVariableSetter == "bash")
+ "~/.local/share/home-manager/env.sh"}
${cfg.profileExtra}
'';
diff --git a/modules/programs/info.nix b/modules/programs/info.nix
index 65f1e3a09..9add7639d 100644
--- a/modules/programs/info.nix
+++ b/modules/programs/info.nix
@@ -60,7 +60,7 @@ in
}];
home.sessionVariables.INFOPATH =
- "${cfg.homeInfoDirLocation}\${INFOPATH:+:}\${INFOPATH}";
+ "${cfg.homeInfoDirLocation}\$INFOPATH:+:\$INFOPATH";
home.activation.createHomeInfoDir = dagEntryAfter ["installPackages"] ''
$DRY_RUN_CMD mkdir -p "${cfg.homeInfoDirLocation}"
diff --git a/modules/services/gpg-agent.nix b/modules/services/gpg-agent.nix
index 1d015397c..fbb0c5e78 100644
--- a/modules/services/gpg-agent.nix
+++ b/modules/services/gpg-agent.nix
@@ -41,7 +41,7 @@ in
home.sessionVariables =
optionalAttrs cfg.enableSshSupport {
- SSH_AUTH_SOCK = "\${XDG_RUNTIME_DIR}/gnupg/S.gpg-agent.ssh";
+ SSH_AUTH_SOCK = "\$XDG_RUNTIME_DIR/gnupg/S.gpg-agent.ssh";
};
programs.bash.initExtra = ''
diff --git a/modules/shell-session-vars.nix b/modules/shell-session-vars.nix
new file mode 100644
index 000000000..c6c37030a
--- /dev/null
+++ b/modules/shell-session-vars.nix
@@ -0,0 +1,26 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+{
+ config = (
+ let
+ export = n: v: "export ${n}=\"${toString v}\"";
+ setenv = n: v: "setenv ${n} \"${toString v}\"";
+ shEnvVarsStr = concatStringsSep "\n" (
+ mapAttrsToList export config.home.sessionVariables
+ );
+ cshEnvVarsStr = concatStringsSep "\n" (
+ mapAttrsToList setenv config.home.sessionVariables
+ );
+ in mkIf (config.home.sessionVariableSetter == "shell"
+ || config.home.sessionVariableSetter == "bash") {
+ home.file.".local/share/home-manager/env.sh".text = ''
+ ${shEnvVarsStr}
+ '';
+ home.file.".local/share/home-manager/env.csh".text = ''
+ ${cshEnvVarsStr}
+ '';
+ }
+ );
+}