mirror of
https://github.com/nix-community/home-manager
synced 2024-11-10 15:14:26 +00:00
c1d8d2a3d1
The NixOS variant of Markdown doesn't make a distinction between `<code>` and `<literal>` or `<quote>` and... quotes, and doesn't support `<parameter>` or `<replaceable>`. These are infrequently used (apart from `<code>`) and don't add much, so just convert them to simpler forms to allow the options containing them to be converted to Markdown automatically. A few minor syntactic adjustments were also made to make `nix-doc-munge`'s job easier.
69 lines
1.9 KiB
Nix
69 lines
1.9 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 ''
|
|
the Home Manager upgrade service that periodically updates your Nix
|
|
channels before running <literal>home-manager switch</literal>'';
|
|
|
|
frequency = lib.mkOption {
|
|
type = lib.types.str;
|
|
example = "weekly";
|
|
description = ''
|
|
The interval at which the Home Manager auto upgrade is run.
|
|
This value is passed to the systemd timer configuration
|
|
as the <literal>OnCalendar</literal> option.
|
|
The format is described in
|
|
<citerefentry>
|
|
<refentrytitle>systemd.time</refentrytitle>
|
|
<manvolnum>7</manvolnum>
|
|
</citerefentry>.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
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
|
|
'');
|
|
};
|
|
};
|
|
};
|
|
}
|