fix(nix/darwin): Fix sessionVariables is being not passed to GUI apps unless it's

opened via terminal
This commit is contained in:
Ahmad Ansori Palembani 2025-03-16 07:32:33 +07:00
parent c4d1bfd8e4
commit 4c7ec25d38
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6

View file

@ -33,6 +33,23 @@
MOZ_ALLOW_DOWNGRADE = 1;
};
# Pass sessionVariables to GUI apps with launchctl
#
# REF: https://github.com/nix-community/home-manager/pull/5801/commits/dbe54a48a0bc9942289f6a5d8a751ed3be065c81
launchd.agents.launchctl-setenv = let
launchctl-setenv = pkgs.writeShellScriptBin "launchctl-setenv"
(concatStringsSep "\n" (mapAttrsToList
(name: val: "/bin/launchctl setenv ${name} ${toString val}")
config.home.sessionVariables));
in {
enable = true;
config = {
ProgramArguments = [ "${launchctl-setenv}/bin/launchctl-setenv" ];
KeepAlive.SuccessfulExit = false;
RunAtLoad = true;
};
};
home.activation.applications = let
env = pkgs.buildEnv {
name = "home-applications";