From 4a7e77f8f9de052517b7db928312a9dce17e69a5 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 11 Nov 2022 18:48:33 +0100 Subject: ... --- accounts/gkleen@eostre.nix | 12 ------------ accounts/mherold@eostre.nix | 12 ------------ hosts/eostre/default.nix | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/accounts/gkleen@eostre.nix b/accounts/gkleen@eostre.nix index 8257d815..e8423976 100644 --- a/accounts/gkleen@eostre.nix +++ b/accounts/gkleen@eostre.nix @@ -5,18 +5,6 @@ ]; config = { - systemd.services."home-manager-${userName}" = { - bindsTo = ["home-${userName}.mount"]; - after = ["home-${userName}.mount"]; - }; - - systemd.mounts = [ - { - where = "/home/${userName}"; - wants = ["home-manager-${userName}.service"]; - } - ]; - home-manager.users.${userName} = { nixpkgs.config = { allowUnfree = true; diff --git a/accounts/mherold@eostre.nix b/accounts/mherold@eostre.nix index 287cabd6..9eb9e738 100644 --- a/accounts/mherold@eostre.nix +++ b/accounts/mherold@eostre.nix @@ -4,18 +4,6 @@ hashedPassword = lib.mkForce "$6$rounds=500000$TaikR1KI4CGveV0a$jLrBjNScflgniUiy87zxQ.IjnyK8K7FbYTW7L0k0EBVrdiImds26WwNjA6DrQpENALwPMzJVIK5BTie17fFVG."; }; - systemd.services."home-manager-${userName}" = { - bindsTo = ["home-${userName}.mount"]; - after = ["home-${userName}.mount"]; - }; - - systemd.mounts = [ - { - where = "/home/${userName}"; - wants = ["home-manager-${userName}.service"]; - } - ]; - home-manager.users.${userName} = { nixpkgs.config = { allowUnfree = true; 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