From 4a7e77f8f9de052517b7db928312a9dce17e69a5 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 11 Nov 2022 18:48:33 +0100 Subject: ... --- hosts/eostre/default.nix | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'hosts/eostre/default.nix') diff --git a/hosts/eostre/default.nix b/hosts/eostre/default.nix index 0603341a..5f58e0a0 100644 --- a/hosts/eostre/default.nix +++ b/hosts/eostre/default.nix @@ -97,5 +97,44 @@ with lib; videoDrivers = [ "nvidia" ]; }; + + systemd.services = mapAttrs' (userName: _: nameValuePair "home-manager-${userName}" { enable = mkForce false; }) config.home-manager.users; + + systemd.user.services."home-manager" = let + cfg = config.home-manager; + in { + description = "Home Manager environment"; + requiredBy = [ "basic.target" ]; + wants = [ "nix-daemon.socket" ]; + after = [ "nix-daemon.socket" ]; + before = [ "basic.target" ]; + + environment = optionalAttrs (cfg.backupFileExtension != null) { + HOME_MANAGER_BACKUP_EXT = cfg.backupFileExtension; + } // optionalAttrs cfg.verbose { VERBOSE = "1"; }; + + stopIfChanged = false; + + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = "yes"; + TimeoutStartSec = 90; + SyslogIdentifier = "hm-activate"; + + ExecStart = pkgs.writeScript "hm-activate" '' + #! ${pkgs.runtimeShell} -el + + case $USER of + ${concatStringsSep "\n " (mapAttrsToList (_: usercfg: builtins.replaceStrings ["\n"] ["\n "] '' + ${usercfg.home.username}) + ${usercfg.home.activationPackage}/activate + systemctl --user daemon-reload + ;; + '') cfg.users)} + *) exit 0; ;; + esac + ''; + }; + }; }; } -- cgit v1.2.3