mirror of
https://github.com/nix-community/home-manager
synced 2024-11-10 07:04:17 +00:00
darwin: Set launchd.user.envVariables from home.sessionVariables
This allows to have consistent environment for both (gui) apps started by launchd and shell programs. Closes: https://github.com/LnL7/nix-darwin/issues/1056 Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com>
This commit is contained in:
parent
471e3eb0a1
commit
130f429bf4
1 changed files with 23 additions and 16 deletions
|
@ -11,21 +11,28 @@ in {
|
|||
|
||||
config = mkMerge [
|
||||
{ home-manager.extraSpecialArgs.darwinConfig = config; }
|
||||
(mkIf (cfg.users != { }) {
|
||||
system.activationScripts.postActivation.text = concatStringsSep "\n"
|
||||
(mapAttrsToList (username: usercfg: ''
|
||||
echo Activating home-manager configuration for ${username}
|
||||
sudo -u ${username} --set-home ${
|
||||
pkgs.writeShellScript "activation-${username}" ''
|
||||
${lib.optionalString (cfg.backupFileExtension != null)
|
||||
"export HOME_MANAGER_BACKUP_EXT=${
|
||||
lib.escapeShellArg cfg.backupFileExtension
|
||||
}"}
|
||||
${lib.optionalString cfg.verbose "export VERBOSE=1"}
|
||||
exec ${usercfg.home.activationPackage}/activate
|
||||
''
|
||||
}
|
||||
'') cfg.users);
|
||||
})
|
||||
(mkIf (cfg.users != { }) (mkMerge [
|
||||
{
|
||||
system.activationScripts.postActivation.text = concatStringsSep "\n"
|
||||
(mapAttrsToList (username: usercfg: ''
|
||||
echo Activating home-manager configuration for ${username}
|
||||
sudo -u ${username} --set-home ${
|
||||
pkgs.writeShellScript "activation-${username}" ''
|
||||
${lib.optionalString (cfg.backupFileExtension != null)
|
||||
"export HOME_MANAGER_BACKUP_EXT=${
|
||||
lib.escapeShellArg cfg.backupFileExtension
|
||||
}"}
|
||||
${lib.optionalString cfg.verbose "export VERBOSE=1"}
|
||||
exec ${usercfg.home.activationPackage}/activate
|
||||
''
|
||||
}
|
||||
'') cfg.users);
|
||||
}
|
||||
{
|
||||
launchd.user.envVariables = mkMerge (map (usercfg:
|
||||
mapAttrs (name: value: toString value) usercfg.home.sessionVariables)
|
||||
(attrValues cfg.users));
|
||||
}
|
||||
]))
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue