From 627157ccebb4c82b6f60c2795e848e595d566dc7 Mon Sep 17 00:00:00 2001 From: Keenan Weaver Date: Sat, 7 Jun 2025 07:37:50 -0500 Subject: [PATCH] ludusavi: modernize and clean-up --- modules/services/ludusavi.nix | 40 ++++++++++++++++------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/modules/services/ludusavi.nix b/modules/services/ludusavi.nix index 043d6391d..f5e6f7a29 100644 --- a/modules/services/ludusavi.nix +++ b/modules/services/ludusavi.nix @@ -6,16 +6,6 @@ }: let - inherit (lib) - getExe - maintainers - mkEnableOption - mkIf - mkOption - ; - - inherit (lib.types) bool nullOr path; - cfg = config.services.ludusavi; settingsFormat = pkgs.formats.yaml { }; @@ -28,16 +18,20 @@ in { options.services.ludusavi = { - enable = mkEnableOption "Ludusavi game backup tool"; - configFile = mkOption { - type = nullOr path; + enable = lib.mkEnableOption "Ludusavi game backup tool"; + + package = lib.mkPackageOption pkgs "ludusavi" { }; + + configFile = lib.mkOption { + type = with lib.types; nullOr path; default = null; description = '' 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. ''; }; - frequency = mkOption { + + frequency = lib.mkOption { type = lib.types.str; default = "daily"; example = "*-*-* 8:00:00"; @@ -48,7 +42,8 @@ in for more information about the format. ''; }; - settings = mkOption { + + settings = lib.mkOption { type = settingsFormat.type; default = { manifest.url = "https://raw.githubusercontent.com/mtkennerly/ludusavi-manifest/master/data/manifest.yaml"; @@ -74,8 +69,9 @@ in for available options. ''; }; - backupNotification = mkOption { - type = bool; + + backupNotification = lib.mkOption { + type = lib.types.bool; default = false; description = '' Send a notification message after a successful backup. @@ -83,7 +79,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { assertions = [ { assertion = (cfg.settings != { }) != (cfg.configFile != null); @@ -97,10 +93,10 @@ in Service = { Type = "oneshot"; - ExecStart = "${getExe pkgs.ludusavi} backup --force"; + ExecStart = "${lib.getExe cfg.package} backup --force"; } // 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 = { @@ -112,8 +108,8 @@ in xdg.configFile."ludusavi/config.yaml".source = configFile; - home.packages = [ pkgs.ludusavi ]; + home.packages = [ cfg.package ]; }; - meta.maintainers = [ maintainers.PopeRigby ]; + meta.maintainers = [ lib.maintainers.PopeRigby ]; }