mirror of
https://github.com/nix-community/home-manager
synced 2024-11-30 15:09:46 +01:00
ludusavi: add @keenanweaver suggestions
This commit is contained in:
parent
0631b47933
commit
b4c309741c
1 changed files with 63 additions and 28 deletions
|
@ -1,31 +1,50 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
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 { };
|
||||||
|
|
||||||
configFile = if cfg.configFile == null then
|
configFile =
|
||||||
settingsFormat.generate "config.yaml" cfg.settings
|
if cfg.configFile == null then
|
||||||
else
|
settingsFormat.generate "config.yaml" cfg.settings
|
||||||
cfg.configFile;
|
else
|
||||||
in {
|
cfg.configFile;
|
||||||
meta.maintainers = [ lib.maintainers.PopeRigby ];
|
in
|
||||||
|
{
|
||||||
|
|
||||||
options.services.ludusavi = {
|
options.services.ludusavi = {
|
||||||
enable = lib.mkEnableOption "Ludusavi game backup tool";
|
enable = mkEnableOption "Ludusavi game backup tool";
|
||||||
configFile = lib.mkOption {
|
configFile = mkOption {
|
||||||
type = with lib.types; nullOr path;
|
type = 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#configuration-file for available options.
|
See https://github.com/mtkennerly/ludusavi/blob/master/docs/help/configuration-file.md for available options.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
settings = lib.mkOption {
|
settings = mkOption {
|
||||||
type = settingsFormat.type;
|
type = settingsFormat.type;
|
||||||
default = {
|
default = {
|
||||||
manifest.url =
|
manifest.url = "https://raw.githubusercontent.com/mtkennerly/ludusavi-manifest/master/data/manifest.yaml";
|
||||||
"https://raw.githubusercontent.com/mtkennerly/ludusavi-manifest/master/data/manifest.yaml";
|
|
||||||
roots = [ ];
|
roots = [ ];
|
||||||
backup.path = "$XDG_STATE_HOME/backups/ludusavi";
|
backup.path = "$XDG_STATE_HOME/backups/ludusavi";
|
||||||
restore.path = "$XDG_STATE_HOME/backups/ludusavi";
|
restore.path = "$XDG_STATE_HOME/backups/ludusavi";
|
||||||
|
@ -33,10 +52,12 @@ in {
|
||||||
example = {
|
example = {
|
||||||
language = "en-US";
|
language = "en-US";
|
||||||
theme = "light";
|
theme = "light";
|
||||||
roots = [{
|
roots = [
|
||||||
path = "~/.local/share/Steam";
|
{
|
||||||
store = "steam";
|
path = "~/.local/share/Steam";
|
||||||
}];
|
store = "steam";
|
||||||
|
}
|
||||||
|
];
|
||||||
backup.path = "~/.local/state/backups/ludusavi";
|
backup.path = "~/.local/state/backups/ludusavi";
|
||||||
restore.path = "~/.local/state/backups/ludusavi";
|
restore.path = "~/.local/state/backups/ludusavi";
|
||||||
};
|
};
|
||||||
|
@ -46,22 +67,34 @@ in {
|
||||||
for available options.
|
for available options.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
backupNotification = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Send a notification message after a successful backup.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
assertions = [{
|
assertions = [
|
||||||
assertion = (cfg.settings != { }) != (cfg.configFile != null);
|
{
|
||||||
message =
|
assertion = (cfg.settings != { }) != (cfg.configFile != null);
|
||||||
"The `settings` and `configFile` options are mutually exclusive.";
|
message = "The `settings` and `configFile` options are mutually exclusive.";
|
||||||
}];
|
}
|
||||||
|
];
|
||||||
|
|
||||||
systemd.user = {
|
systemd.user = {
|
||||||
services.ludusavi = {
|
services.ludusavi = {
|
||||||
Unit.Description = "Run a game save backup with Ludusavi";
|
Unit.Description = "Run a game save backup with Ludusavi";
|
||||||
Service = {
|
Service =
|
||||||
Type = "oneshot";
|
{
|
||||||
ExecStart = "${pkgs.ludusavi}/bin/ludusavi backup --force";
|
Type = "oneshot";
|
||||||
};
|
ExecStart = "${getExe pkgs.ludusavi} backup --force";
|
||||||
|
}
|
||||||
|
// lib.optionalAttrs cfg.backupNotification {
|
||||||
|
ExecStartPost = "${getExe pkgs.libnotify} 'Ludusavi' 'Backup completed' -i com.github.mtkennerly.ludusavi -a 'Ludusavi'";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
timers.ludusavi = {
|
timers.ludusavi = {
|
||||||
Unit.Description = "Run a game save backup with Ludusavi, daily";
|
Unit.Description = "Run a game save backup with Ludusavi, daily";
|
||||||
|
@ -74,4 +107,6 @@ in {
|
||||||
|
|
||||||
home.packages = [ pkgs.ludusavi ];
|
home.packages = [ pkgs.ludusavi ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
meta.maintainers = [ maintainers.PopeRigby ];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue