mirror of
https://github.com/nix-community/home-manager
synced 2024-11-30 15:09:46 +01:00
36a53d9f26
This process was automated by [my fork of `nix-doc-munge`]. All conversions were automatically checked to produce the same DocBook result when converted back, modulo minor typographical/formatting differences on the acceptable-to-desirable spectrum. To reproduce this commit, run: $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \ nix shell nixpkgs#coreutils \ -c find . -name '*.nix' \ -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \ {} + $ ./format [my fork of `nix-doc-munge`]: https://github.com/emilazy/nix-doc-munge/tree/home-manager
66 lines
1.8 KiB
Nix
66 lines
1.8 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.services.home-manager.autoUpgrade;
|
|
|
|
homeManagerPackage = pkgs.callPackage ../../home-manager {
|
|
path = config.programs.home-manager.path;
|
|
};
|
|
|
|
in {
|
|
meta.maintainers = [ lib.hm.maintainers.pinage404 ];
|
|
|
|
options = {
|
|
services.home-manager.autoUpgrade = {
|
|
enable = lib.mkEnableOption (lib.mdDoc ''
|
|
the Home Manager upgrade service that periodically updates your Nix
|
|
channels before running `home-manager switch`'');
|
|
|
|
frequency = lib.mkOption {
|
|
type = lib.types.str;
|
|
example = "weekly";
|
|
description = lib.mdDoc ''
|
|
The interval at which the Home Manager auto upgrade is run.
|
|
This value is passed to the systemd timer configuration
|
|
as the `OnCalendar` option.
|
|
The format is described in
|
|
{manpage}`systemd.time(7)`.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
assertions = [
|
|
(lib.hm.assertions.assertPlatform "services.home-manager.autoUpgrade" pkgs
|
|
lib.platforms.linux)
|
|
];
|
|
|
|
systemd.user = {
|
|
timers.home-manager-auto-upgrade = {
|
|
Unit.Description = "Home Manager upgrade timer";
|
|
|
|
Install.WantedBy = [ "timers.target" ];
|
|
|
|
Timer = {
|
|
OnCalendar = cfg.frequency;
|
|
Unit = "home-manager-auto-upgrade.service";
|
|
Persistent = true;
|
|
};
|
|
};
|
|
|
|
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
|
|
'');
|
|
};
|
|
};
|
|
};
|
|
}
|