From 1f2ba895a098338318bbc02119b7d65ec9a6a106 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Sun, 27 Nov 2022 21:57:34 +0100 Subject: [PATCH] Clean some sessionVariables from global scope Especially some XDG_* env vars polluted other users environment when set globally --- modules/terminal-life/default.nix | 9 ++++---- profiles/base-user/session-variables.nix | 29 ++++++++++++------------ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/modules/terminal-life/default.nix b/modules/terminal-life/default.nix index 6bd0312f..39571b48 100644 --- a/modules/terminal-life/default.nix +++ b/modules/terminal-life/default.nix @@ -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 diff --git a/profiles/base-user/session-variables.nix b/profiles/base-user/session-variables.nix index e922781b..71471c05 100644 --- a/profiles/base-user/session-variables.nix +++ b/profiles/base-user/session-variables.nix @@ -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; }