From 58473a3c1a7e424fca88eb1f954e153deb51a2d8 Mon Sep 17 00:00:00 2001 From: MickaelRoger Date: Thu, 26 Sep 2024 22:13:28 +0200 Subject: [PATCH] nixos/anki-sync-server: add setting There is no option to specify where the anki-sync-server data will be stored. This commit adds this option. --- nixos/modules/services/misc/anki-sync-server.md | 9 +++++++++ nixos/modules/services/misc/anki-sync-server.nix | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/misc/anki-sync-server.md b/nixos/modules/services/misc/anki-sync-server.md index 4796abf25c43..1210cad6d0af 100644 --- a/nixos/modules/services/misc/anki-sync-server.md +++ b/nixos/modules/services/misc/anki-sync-server.md @@ -42,6 +42,15 @@ Here, `passwordFile` is the path to a file containing just the password in plaintext. Make sure to set permissions to make this file unreadable to any user besides root. +By default, synced data are stored in */var/lib/anki-sync-server/*ankiuser**. +You can change the directory by using `services.anki-sync-server.baseDirectory` + +```nix +{ + services.anki-sync-server.baseDirectory = "/home/anki/data"; +} +``` + By default, the server listen address {option}`services.anki-sync-server.host` is set to localhost, listening on port {option}`services.anki-sync-server.port`, and does not open the firewall. This diff --git a/nixos/modules/services/misc/anki-sync-server.nix b/nixos/modules/services/misc/anki-sync-server.nix index a65382009417..c77afe8c3819 100644 --- a/nixos/modules/services/misc/anki-sync-server.nix +++ b/nixos/modules/services/misc/anki-sync-server.nix @@ -59,6 +59,13 @@ in { description = "Port number anki-sync-server listens to."; }; + baseDirectory = mkOption { + type = types.str; + default = "%S/%N"; + description = "Base directory where user(s) synchronized data will be stored."; + }; + + openFirewall = mkOption { default = false; type = types.bool; @@ -114,7 +121,7 @@ in { wantedBy = ["multi-user.target"]; path = [cfg.package]; environment = { - SYNC_BASE = "%S/%N"; + SYNC_BASE = cfg.baseDirectory; SYNC_HOST = specEscape cfg.address; SYNC_PORT = toString cfg.port; };