mirror of
https://github.com/nix-community/home-manager.git
synced 2026-01-11 17:39:37 +08:00
ludusavi: modernize and clean-up
This commit is contained in:
committed by
Austin Horstman
parent
bc0012d036
commit
627157cceb
@@ -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 ];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user