2.home-manager/modules/services/tldr-update.nix
Austin Horstman 165228b0ef
Some checks are pending
/ triage (push) Waiting to run
GitHub Pages / publish (ubuntu-latest) (push) Waiting to run
launchd: restore gui domain defaults
User-domain agents are not rediscovered from the user LaunchAgents directory after reboot. Let built-in agents inherit the GUI default while keeping explicit user-domain configuration available.
2026-07-15 10:29:26 -05:00

74 lines
1.6 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.tldr-update;
in
{
meta.maintainers = [ lib.maintainers.PerchunPak ];
options.services.tldr-update = {
enable = lib.mkEnableOption ''
Automatic updates for the tldr CLI
'';
package = lib.mkPackageOption pkgs "tldr" { example = "tlrc"; };
period = lib.mkOption {
type = lib.types.str;
default = "weekly";
description = ''
Systemd timer period to create for scheduled {command}`tldr --update`.
On Linux this is a string as defined by {manpage}`systemd.time(7)`.
${lib.hm.darwin.intervalDocumentation}
'';
};
};
config = lib.mkIf cfg.enable {
systemd.user.services.tldr-update = {
Unit = {
Description = "Update tldr CLI cache";
Documentation = "https://tldr.sh/";
};
Service = {
Type = "oneshot";
ExecStart = ''
${lib.getExe cfg.package} --update
'';
};
};
systemd.user.timers.tldr-update = {
Unit.Description = "Update tldr CLI cache";
Timer = {
OnCalendar = cfg.period;
Persistent = true;
};
Install.WantedBy = [ "timers.target" ];
};
assertions = [
(lib.hm.darwin.assertInterval "services.tldr-update.period" cfg.period pkgs)
];
launchd.agents.tldr-update = {
enable = true;
config = {
ProgramArguments = [
(lib.getExe cfg.package)
"--update"
];
StartCalendarInterval = lib.hm.darwin.mkCalendarInterval cfg.period;
};
};
};
}