diff --git a/modules/services/home-manager-auto-upgrade.nix b/modules/services/home-manager-auto-upgrade.nix index 659f91181..a1cadeee5 100644 --- a/modules/services/home-manager-auto-upgrade.nix +++ b/modules/services/home-manager-auto-upgrade.nix @@ -8,6 +8,16 @@ let path = config.programs.home-manager.path; }; + autoUpgradeApp = pkgs.writeShellApplication { + name = "home-manager-auto-upgrade"; + text = '' + echo "Update Nix's channels" + nix-channel --update + echo "Upgrade Home Manager" + home-manager switch + ''; + runtimeInputs = with pkgs; [ homeManagerPackage nix ]; + }; in { meta.maintainers = [ lib.hm.maintainers.pinage404 ]; @@ -52,14 +62,7 @@ in { services.home-manager-auto-upgrade = { Unit.Description = "Home Manager upgrade"; - - Service.ExecStart = toString - (pkgs.writeShellScript "home-manager-auto-upgrade" '' - echo "Update Nix's channels" - ${pkgs.nix}/bin/nix-channel --update - echo "Upgrade Home Manager" - ${homeManagerPackage}/bin/home-manager switch - ''); + Service.ExecStart = "${autoUpgradeApp}/bin/home-manager-auto-upgrade"; }; }; };