2024-07-10 05:21:34 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2024-07-10 05:19:19 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.ludusavi;
|
|
|
|
settingsFormat = pkgs.formats.yaml { };
|
|
|
|
|
2024-07-10 05:21:34 +02:00
|
|
|
configFile = if cfg.configFile == null then
|
|
|
|
settingsFormat.generate "config.yaml" cfg.settings
|
|
|
|
else
|
|
|
|
cfg.configFile;
|
|
|
|
in {
|
2024-07-10 05:19:19 +02:00
|
|
|
meta.maintainers = [ lib.maintainers.PopeRigby ];
|
|
|
|
|
|
|
|
options.services.ludusavi = {
|
|
|
|
enable = lib.mkEnableOption "Ludusavi game backup tool";
|
|
|
|
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#configuration-file for available options.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
settings = lib.mkOption {
|
|
|
|
type = settingsFormat.type;
|
|
|
|
default = {
|
2024-07-10 05:21:34 +02:00
|
|
|
manifest.url =
|
|
|
|
"https://raw.githubusercontent.com/mtkennerly/ludusavi-manifest/master/data/manifest.yaml";
|
2024-07-10 05:19:19 +02:00
|
|
|
roots = [ ];
|
2024-08-04 20:47:57 +02:00
|
|
|
backup.path = "$XDG_STATE_HOME/backups/ludusavi";
|
|
|
|
restore.path = "$XDG_STATE_HOME/backups/ludusavi";
|
2024-07-10 05:19:19 +02:00
|
|
|
};
|
|
|
|
example = {
|
|
|
|
language = "en-US";
|
|
|
|
theme = "light";
|
2024-07-10 05:21:34 +02:00
|
|
|
roots = [{
|
|
|
|
path = "~/.local/share/Steam";
|
|
|
|
store = "steam";
|
|
|
|
}];
|
2024-07-10 05:19:19 +02:00
|
|
|
backup.path = "~/.local/state/backups/ludusavi";
|
|
|
|
restore.path = "~/.local/state/backups/ludusavi";
|
|
|
|
};
|
|
|
|
description = ''
|
|
|
|
Ludusavi configuration as an attribute set. See
|
|
|
|
https://github.com/mtkennerly/ludusavi#configuration-file
|
|
|
|
for available options.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
2024-07-10 05:21:34 +02:00
|
|
|
assertions = [{
|
|
|
|
assertion = (cfg.settings != { }) != (cfg.configFile != null);
|
|
|
|
message =
|
|
|
|
"The `settings` and `configFile` options are mutually exclusive.";
|
|
|
|
}];
|
2024-07-10 05:19:19 +02:00
|
|
|
|
|
|
|
systemd.user = {
|
|
|
|
services.ludusavi = {
|
|
|
|
Unit.Description = "Run a game save backup with Ludusavi";
|
|
|
|
Service = {
|
|
|
|
Type = "oneshot";
|
|
|
|
ExecStart = "${pkgs.ludusavi}/bin/ludusavi backup --force";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
timers.ludusavi = {
|
|
|
|
Unit.Description = "Run a game save backup with Ludusavi, daily";
|
|
|
|
Timer.OnCalendar = "daily";
|
|
|
|
Install.WantedBy = [ "timers.target" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
xdg.configFile."ludusavi/config.yaml".source = configFile;
|
|
|
|
|
|
|
|
home.packages = [ pkgs.ludusavi ];
|
|
|
|
};
|
|
|
|
}
|