Clean some sessionVariables from global scope

Especially some XDG_* env vars polluted other users environment when set

globally
This commit is contained in:
teutat3s 2022-11-27 21:57:34 +01:00
parent a795bf4429
commit 1f2ba895a0
Signed by: teutat3s
GPG key ID: 4FA1D3FA524F22C1
2 changed files with 20 additions and 18 deletions

View file

@ -28,16 +28,17 @@ in
];
environment.systemPackages = with pkgs; [
ack
bat
exa
fd
neovim
screen
];
home-manager = with pkgs; pkgs.lib.setAttrByPath [ "users" psCfg.user.name ] {
home.packages = [
ack
asciinema
bat
exa
fd
gh
glow
nnn

View file

@ -3,7 +3,14 @@ let
psCfg = config.pub-solar;
wlroots = psCfg.graphical.wayland;
xdg = config.home-manager.users."${psCfg.user.name}".xdg;
variables = {
globalVariables = {
EDITOR = "/run/current-system/sw/bin/nvim";
VISUAL = "/run/current-system/sw/bin/nvim";
# Make sure virsh runs without root
LIBVIRT_DEFAULT_URI = "qemu:///system";
};
userVariables = {
XDG_CONFIG_HOME = xdg.configHome;
XDG_CACHE_HOME = xdg.cacheHome;
XDG_DATA_HOME = xdg.dataHome;
@ -18,11 +25,8 @@ let
SDL_VIDEODRIVER = "wayland";
WLR_RENDERER = if wlroots.software-renderer.enable then "pixman" else "gles2";
EDITOR = "/etc/profiles/per-user/${psCfg.user.name}/bin/nvim";
VISUAL = "/etc/profiles/per-user/${psCfg.user.name}/bin/nvim";
# fix "xdg-open fork-bomb" your preferred browser from here
BROWSER = "${pkgs.firefox-wayland}/bin/firefox";
BROWSER = "firefox";
# node
NODE_REPL_HISTORY = "${xdg.dataHome}/node_repl_history";
@ -34,9 +38,6 @@ let
NPM_CONFIG_CACHE = "${xdg.configHome}/npm";
# TODO: used to be XDG_RUNTIME_DIR NPM_CONFIG_TMP = "/tmp/npm";
# Make sure virsh runs without root
LIBVIRT_DEFAULT_URI = "qemu:///system";
# wine
WINEPREFIX = "${xdg.dataHome}/wineprefixes/default";
@ -78,21 +79,21 @@ let
VUEDX_TELEMETRY = "off";
};
envListNames = lib.attrsets.mapAttrsToList (name: value: name) variables;
envListNames = lib.attrsets.mapAttrsToList (name: value: name) userVariables;
# Here we merge an extra variable into the attrset called FULL_ENV_LIST.
# It's a list of the variable names defined above.
# We can use this to tell `systemctl import-environment` to import the full list above.
variablesWithMeta = lib.attrsets.zipAttrsWith (name: values: builtins.head values) [
variables
userVariablesWithMeta = lib.attrsets.zipAttrsWith (name: values: builtins.head values) [
userVariables
{ IMPORT_ENVIRONMENT_ENV_LIST = lib.lists.foldl (a: b: a + " " + b) "IMPORT_ENVIRONMENT_ENV_LIST" envListNames; }
];
in
{
home-manager = pkgs.lib.setAttrByPath [ "users" psCfg.user.name ] {
home.sessionVariables = variablesWithMeta;
systemd.user.sessionVariables = variablesWithMeta;
home.sessionVariables = userVariablesWithMeta;
systemd.user.sessionVariables = userVariablesWithMeta;
};
environment.variables = variablesWithMeta;
environment.variables = globalVariables;
}