diff --git a/modules/programs/hypr/land/default.nix b/modules/programs/hypr/land/default.nix index ef71dd6..69cb7b0 100644 --- a/modules/programs/hypr/land/default.nix +++ b/modules/programs/hypr/land/default.nix @@ -11,6 +11,7 @@ inherit (config.local.systemVars) username; styleCfg = config.local.style; + gnomeControlCenter = pkgs.gnome-control-center.overrideAttrs (old: { postInstall = old.postInstall @@ -155,6 +156,8 @@ in { } // import ./binds.nix lib; }; + + ".config/uwsm/env-hyprland".source = config.hjem.users.${username}.environment.setEnvironment; }; environment.sessionVariables = mkMerge [ diff --git a/shared/modules/hjem/collection/environment.nix b/shared/modules/hjem/collection/environment.nix index f306015..d11dd93 100644 --- a/shared/modules/hjem/collection/environment.nix +++ b/shared/modules/hjem/collection/environment.nix @@ -12,6 +12,8 @@ inherit (lib.types) attrsOf listOf oneOf int path str; inherit (pkgs) writeShellScript; + cfg = config.environment; + toEnv = env: if isList env then concatStringsSep ":" (map toString env) @@ -21,39 +23,37 @@ (mapAttrsToList (name: value: "export ${name}=\"${toEnv value}\"") vars)); writeEnvScript = attrs: - writeShellScript "load-env" - ( - '' - # Only execute this file once per shell. - if [ -n "$__ETC_PROFILE_SOURCED" ]; then return; fi - __ETC_PROFILE_SOURCED=1 - # Prevent this file from being sourced by interactive non-login child shells. - export __ETC_PROFILE_DONE=1 - # Session variables - '' - + mkEnvVars attrs - ); + writeShellScript "set-environment" + (mkEnvVars attrs); in { - options.environment.sessionVariables = mkOption { - type = attrsOf (oneOf [(listOf (oneOf [int str path])) int str path]); - default = {}; - example = { - EDITOR = "nvim"; - VISUAL = "nvim"; + options.environment = { + setEnvironment = mkOption { + type = path; + readOnly = true; + description = '' + A POSIX compliant shell script containing the user session variables needed to bootstrap the session. + + As there is no reliable and agnostic way of setting session variables, Hjem's + environment module does nothing by itself. Rather, it provides a POSIX compliant shell script + that needs to be sourced where needed. + ''; + }; + sessionVariables = mkOption { + type = attrsOf (oneOf [(listOf (oneOf [int str path])) int str path]); + default = {}; + example = { + EDITOR = "nvim"; + VISUAL = "nvim"; + }; + description = '' + A set of environment variables used in the user environment. + If a list of strings is used, they will be concatenated with colon + characters. + ''; }; - description = '' - A set of environment variables used in the user environment. - If a list of strings is used, they will be concatenated with colon - characters. - ''; }; - config = mkIf (config.environment.sessionVariables != {}) { - files = { - ".profile".text = '' - . ${writeEnvScript config.environment.sessionVariables} - ''; - ".config/uwsm/env".text = mkEnvVars config.environment.sessionVariables; - }; + config = mkIf (cfg.sessionVariables != {}) { + environment.setEnvironment = writeEnvScript cfg.sessionVariables; }; }