nixpkgs/nixos/modules/services/misc/ankisyncd.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

73 lines
1.8 KiB
Nix
Raw Normal View History

2020-03-09 21:08:44 +00:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.ankisyncd;
name = "ankisyncd";
stateDir = "/var/lib/${name}";
toml = pkgs.formats.toml {};
2020-03-09 21:08:44 +00:00
configFile = toml.generate "ankisyncd.conf" {
listen = {
2020-03-09 21:08:44 +00:00
host = cfg.host;
port = cfg.port;
};
paths.root_dir = stateDir;
# encryption.ssl_enable / cert_file / key_file
};
2020-03-09 21:08:44 +00:00
in
{
options.services.ankisyncd = {
enable = mkEnableOption "ankisyncd, a standalone unofficial anky sync server";
2020-03-09 21:08:44 +00:00
package = mkPackageOption pkgs "ankisyncd" { };
2020-03-09 21:08:44 +00:00
host = mkOption {
type = types.str;
default = "localhost";
description = "ankisyncd host";
};
port = mkOption {
type = types.port;
2020-03-09 21:08:44 +00:00
default = 27701;
description = "ankisyncd port";
};
openFirewall = mkOption {
default = false;
type = types.bool;
description = "Whether to open the firewall for the specified port.";
};
};
config = mkIf cfg.enable {
2023-12-01 12:17:21 +00:00
warnings = [
''
`services.ankisyncd` has been replaced by `services.anki-sync-server` and will be removed after
24.05 because anki-sync-server(-rs and python) are not maintained.
''
];
2020-03-09 21:08:44 +00:00
networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ];
systemd.services.ankisyncd = {
description = "ankisyncd - Anki sync server";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
path = [ cfg.package ];
serviceConfig = {
Type = "simple";
DynamicUser = true;
StateDirectory = name;
ExecStart = "${cfg.package}/bin/ankisyncd --config ${configFile}";
2020-03-09 21:08:44 +00:00
Restart = "always";
};
};
};
}