diff options
author | Léo Gaspard <leo@gaspard.io> | 2020-03-12 11:47:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-12 11:47:42 +0100 |
commit | 06bdfc5e3218cdbe7b4ef9ce601da65e78ef9d25 (patch) | |
tree | 53f1f715ec35825338776a64f6c4bca6114006ea /nixos | |
parent | 397288d14e64748e5d2e6a1b391fcbc40b1d9d8d (diff) | |
parent | acba458b7ed7f64336081dd2a29856be9cb8de00 (diff) | |
download | nixlib-06bdfc5e3218cdbe7b4ef9ce601da65e78ef9d25.tar nixlib-06bdfc5e3218cdbe7b4ef9ce601da65e78ef9d25.tar.gz nixlib-06bdfc5e3218cdbe7b4ef9ce601da65e78ef9d25.tar.bz2 nixlib-06bdfc5e3218cdbe7b4ef9ce601da65e78ef9d25.tar.lz nixlib-06bdfc5e3218cdbe7b4ef9ce601da65e78ef9d25.tar.xz nixlib-06bdfc5e3218cdbe7b4ef9ce601da65e78ef9d25.tar.zst nixlib-06bdfc5e3218cdbe7b4ef9ce601da65e78ef9d25.zip |
Merge pull request #82185 from matt-snider/master
ankisyncd, nixos/ankisyncd: init at 2.1.0
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/module-list.nix | 1 | ||||
-rw-r--r-- | nixos/modules/services/misc/ankisyncd.nix | 79 |
2 files changed, 80 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 917840fb9195..dba2593bbef5 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -406,6 +406,7 @@ ./services/mail/sympa.nix ./services/mail/nullmailer.nix ./services/misc/airsonic.nix + ./services/misc/ankisyncd.nix ./services/misc/apache-kafka.nix ./services/misc/autofs.nix ./services/misc/autorandr.nix diff --git a/nixos/modules/services/misc/ankisyncd.nix b/nixos/modules/services/misc/ankisyncd.nix new file mode 100644 index 000000000000..5fc19649d3d9 --- /dev/null +++ b/nixos/modules/services/misc/ankisyncd.nix @@ -0,0 +1,79 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.ankisyncd; + + name = "ankisyncd"; + + stateDir = "/var/lib/${name}"; + + authDbPath = "${stateDir}/auth.db"; + + sessionDbPath = "${stateDir}/session.db"; + + configFile = pkgs.writeText "ankisyncd.conf" (lib.generators.toINI {} { + sync_app = { + host = cfg.host; + port = cfg.port; + data_root = stateDir; + auth_db_path = authDbPath; + session_db_path = sessionDbPath; + + base_url = "/sync/"; + base_media_url = "/msync/"; + }; + }); +in + { + options.services.ankisyncd = { + enable = mkEnableOption "ankisyncd"; + + package = mkOption { + type = types.package; + default = pkgs.ankisyncd; + defaultText = literalExample "pkgs.ankisyncd"; + description = "The package to use for the ankisyncd command."; + }; + + host = mkOption { + type = types.str; + default = "localhost"; + description = "ankisyncd host"; + }; + + port = mkOption { + type = types.int; + 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 { + networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ]; + + environment.etc."ankisyncd/ankisyncd.conf".source = configFile; + + 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"; + Restart = "always"; + }; + }; + }; + } |