mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-14 13:01:09 +01:00
tldr-update: init (#6401)
Adds `tldr-update` module for enabling automatic `tldr update` on a schedule. Adds option to `tealdeer` to enable integration with new `tldr-update` module.
This commit is contained in:
parent
5af1b9a0f1
commit
b0bd29bb4b
8 changed files with 101 additions and 0 deletions
|
|
@ -394,6 +394,7 @@ let
|
|||
./services/taffybar.nix
|
||||
./services/tahoe-lafs.nix
|
||||
./services/taskwarrior-sync.nix
|
||||
./services/tldr-update.nix
|
||||
./services/trayer.nix
|
||||
./services/trayscale.nix
|
||||
./services/twmn.nix
|
||||
|
|
|
|||
|
|
@ -80,6 +80,11 @@ in {
|
|||
See <https://tealdeer-rs.github.io/tealdeer/config.html> for more information.
|
||||
'';
|
||||
};
|
||||
|
||||
enableAutoUpdates = mkEnableOption "Auto updates" // {
|
||||
default = true;
|
||||
example = false;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
|
@ -89,5 +94,10 @@ in {
|
|||
mkIf (cfg.settings != null && cfg.settings != { }) {
|
||||
source = tomlFormat.generate "tealdeer-config" cfg.settings;
|
||||
};
|
||||
|
||||
services.tldr-update = mkIf cfg.enableAutoUpdates {
|
||||
enable = true;
|
||||
package = pkgs.tealdeer;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
50
modules/services/tldr-update.nix
Normal file
50
modules/services/tldr-update.nix
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
let cfg = config.services.tldr-update;
|
||||
in {
|
||||
meta.maintainers = [ lib.maintainers.perchun ];
|
||||
|
||||
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`.
|
||||
|
||||
The format is described in {manpage}`systemd.time(7)`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
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" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -370,6 +370,7 @@ in import nmtSrc {
|
|||
./modules/services/swayosd
|
||||
./modules/services/sxhkd
|
||||
./modules/services/syncthing/linux
|
||||
./modules/services/tldr-update
|
||||
./modules/services/trayer
|
||||
./modules/services/trayscale
|
||||
./modules/services/twmn
|
||||
|
|
|
|||
1
tests/modules/services/tldr-update/default.nix
Normal file
1
tests/modules/services/tldr-update/default.nix
Normal file
|
|
@ -0,0 +1 @@
|
|||
{ tldr-update = ./tldr-update.nix; }
|
||||
21
tests/modules/services/tldr-update/tldr-update.nix
Normal file
21
tests/modules/services/tldr-update/tldr-update.nix
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{ config, ... }:
|
||||
|
||||
{
|
||||
config = {
|
||||
home.stateVersion = "24.11";
|
||||
|
||||
services.tldr-update = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { outPath = "@tldr@"; };
|
||||
period = "monthly";
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
serviceFile=$(normalizeStorePaths home-files/.config/systemd/user/tldr-update.service)
|
||||
assertFileContent "$serviceFile" ${./tldr-update.service}
|
||||
|
||||
timerFile=$(normalizeStorePaths home-files/.config/systemd/user/tldr-update.timer)
|
||||
assertFileContent "$timerFile" ${./tldr-update.timer}
|
||||
'';
|
||||
};
|
||||
}
|
||||
8
tests/modules/services/tldr-update/tldr-update.service
Normal file
8
tests/modules/services/tldr-update/tldr-update.service
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[Service]
|
||||
ExecStart=@tldr@/bin/dummy --update
|
||||
|
||||
Type=oneshot
|
||||
|
||||
[Unit]
|
||||
Description=Update tldr CLI cache
|
||||
Documentation=https://tldr.sh/
|
||||
9
tests/modules/services/tldr-update/tldr-update.timer
Normal file
9
tests/modules/services/tldr-update/tldr-update.timer
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[Install]
|
||||
WantedBy=timers.target
|
||||
|
||||
[Timer]
|
||||
OnCalendar=monthly
|
||||
Persistent=true
|
||||
|
||||
[Unit]
|
||||
Description=Update tldr CLI cache
|
||||
Loading…
Add table
Add a link
Reference in a new issue