1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-21 09:49:39 +01:00

ludusavi: modernize and clean-up

This commit is contained in:
Keenan Weaver 2025-06-07 07:37:50 -05:00 committed by Austin Horstman
parent bc0012d036
commit 627157cceb

View file

@ -6,16 +6,6 @@
}: }:
let let
inherit (lib)
getExe
maintainers
mkEnableOption
mkIf
mkOption
;
inherit (lib.types) bool nullOr path;
cfg = config.services.ludusavi; cfg = config.services.ludusavi;
settingsFormat = pkgs.formats.yaml { }; settingsFormat = pkgs.formats.yaml { };
@ -28,16 +18,20 @@ in
{ {
options.services.ludusavi = { options.services.ludusavi = {
enable = mkEnableOption "Ludusavi game backup tool"; enable = lib.mkEnableOption "Ludusavi game backup tool";
configFile = mkOption {
type = nullOr path; package = lib.mkPackageOption pkgs "ludusavi" { };
configFile = lib.mkOption {
type = with lib.types; nullOr path;
default = null; default = null;
description = '' description = ''
Path to a Ludusavi `config.yaml`. Mutually exclusive with the `settings` option. Path to a Ludusavi `config.yaml`. Mutually exclusive with the `settings` option.
See https://github.com/mtkennerly/ludusavi/blob/master/docs/help/configuration-file.md for available options. See https://github.com/mtkennerly/ludusavi/blob/master/docs/help/configuration-file.md for available options.
''; '';
}; };
frequency = mkOption {
frequency = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "daily"; default = "daily";
example = "*-*-* 8:00:00"; example = "*-*-* 8:00:00";
@ -48,7 +42,8 @@ in
for more information about the format. for more information about the format.
''; '';
}; };
settings = mkOption {
settings = lib.mkOption {
type = settingsFormat.type; type = settingsFormat.type;
default = { default = {
manifest.url = "https://raw.githubusercontent.com/mtkennerly/ludusavi-manifest/master/data/manifest.yaml"; manifest.url = "https://raw.githubusercontent.com/mtkennerly/ludusavi-manifest/master/data/manifest.yaml";
@ -74,8 +69,9 @@ in
for available options. for available options.
''; '';
}; };
backupNotification = mkOption {
type = bool; backupNotification = lib.mkOption {
type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Send a notification message after a successful backup. Send a notification message after a successful backup.
@ -83,7 +79,7 @@ in
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
assertions = [ assertions = [
{ {
assertion = (cfg.settings != { }) != (cfg.configFile != null); assertion = (cfg.settings != { }) != (cfg.configFile != null);
@ -97,10 +93,10 @@ in
Service = Service =
{ {
Type = "oneshot"; Type = "oneshot";
ExecStart = "${getExe pkgs.ludusavi} backup --force"; ExecStart = "${lib.getExe cfg.package} backup --force";
} }
// lib.optionalAttrs cfg.backupNotification { // lib.optionalAttrs cfg.backupNotification {
ExecStartPost = "${getExe pkgs.libnotify} 'Ludusavi' 'Backup completed' -i com.mtkennerly.ludusavi -a 'Ludusavi'"; ExecStartPost = "${lib.getExe pkgs.libnotify} 'Ludusavi' 'Backup completed' -i com.mtkennerly.ludusavi -a 'Ludusavi'";
}; };
}; };
timers.ludusavi = { timers.ludusavi = {
@ -112,8 +108,8 @@ in
xdg.configFile."ludusavi/config.yaml".source = configFile; xdg.configFile."ludusavi/config.yaml".source = configFile;
home.packages = [ pkgs.ludusavi ]; home.packages = [ cfg.package ];
}; };
meta.maintainers = [ maintainers.PopeRigby ]; meta.maintainers = [ lib.maintainers.PopeRigby ];
} }