diff options
author | Matt Snider <matt.snider@protonmail.com> | 2020-03-27 10:26:17 +0100 |
---|---|---|
committer | Matt Snider <matt.snider@protonmail.com> | 2021-02-17 10:43:08 +0100 |
commit | 58058515a34862b69b53e1d3500599a33ea610d7 (patch) | |
tree | ba7e73a9e3caad05f83bfdbb68f42b353d4acd8b | |
parent | 2fe492c198da46231700c8152f4c6ff885f1ef6b (diff) | |
download | nixpkgs-58058515a34862b69b53e1d3500599a33ea610d7.tar nixpkgs-58058515a34862b69b53e1d3500599a33ea610d7.tar.gz nixpkgs-58058515a34862b69b53e1d3500599a33ea610d7.tar.bz2 nixpkgs-58058515a34862b69b53e1d3500599a33ea610d7.tar.lz nixpkgs-58058515a34862b69b53e1d3500599a33ea610d7.tar.xz nixpkgs-58058515a34862b69b53e1d3500599a33ea610d7.tar.zst nixpkgs-58058515a34862b69b53e1d3500599a33ea610d7.zip |
nixos/etesync-dav: init module
-rw-r--r-- | nixos/modules/module-list.nix | 1 | ||||
-rw-r--r-- | nixos/modules/services/misc/etesync-dav.nix | 92 |
2 files changed, 93 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 3055459e781..644229627b2 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -461,6 +461,7 @@ ./services/misc/errbot.nix ./services/misc/etcd.nix ./services/misc/etebase-server.nix + ./services/misc/etesync-dav.nix ./services/misc/ethminer.nix ./services/misc/exhibitor.nix ./services/misc/felix.nix diff --git a/nixos/modules/services/misc/etesync-dav.nix b/nixos/modules/services/misc/etesync-dav.nix new file mode 100644 index 00000000000..9d7cfda371b --- /dev/null +++ b/nixos/modules/services/misc/etesync-dav.nix @@ -0,0 +1,92 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.etesync-dav; +in + { + options.services.etesync-dav = { + enable = mkEnableOption "etesync-dav"; + + host = mkOption { + type = types.str; + default = "localhost"; + description = "The server host address."; + }; + + port = mkOption { + type = types.port; + default = 37358; + description = "The server host port."; + }; + + apiUrl = mkOption { + type = types.str; + default = "https://api.etesync.com/"; + description = "The url to the etesync API."; + }; + + openFirewall = mkOption { + default = false; + type = types.bool; + description = "Whether to open the firewall for the specified port."; + }; + + sslCertificate = mkOption { + type = types.nullOr types.path; + default = null; + example = "/var/etesync.crt"; + description = '' + Path to server SSL certificate. It will be copied into + etesync-dav's data directory. + ''; + }; + + sslCertificateKey = mkOption { + type = types.nullOr types.path; + default = null; + example = "/var/etesync.key"; + description = '' + Path to server SSL certificate key. It will be copied into + etesync-dav's data directory. + ''; + }; + }; + + config = mkIf cfg.enable { + networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ]; + + systemd.services.etesync-dav = { + description = "etesync-dav - A CalDAV and CardDAV adapter for EteSync"; + after = [ "network-online.target" ]; + wantedBy = [ "multi-user.target" ]; + path = [ pkgs.etesync-dav ]; + environment = { + ETESYNC_LISTEN_ADDRESS = cfg.host; + ETESYNC_LISTEN_PORT = toString cfg.port; + ETESYNC_URL = cfg.apiUrl; + ETESYNC_DATA_DIR = "/var/lib/etesync-dav"; + }; + + serviceConfig = { + Type = "simple"; + DynamicUser = true; + StateDirectory = "etesync-dav"; + ExecStart = "${pkgs.etesync-dav}/bin/etesync-dav"; + ExecStartPre = mkIf (cfg.sslCertificate != null || cfg.sslCertificateKey != null) ( + pkgs.writers.writeBash "etesync-dav-copy-keys" '' + ${optionalString (cfg.sslCertificate != null) '' + cp ${toString cfg.sslCertificate} $STATE_DIRECTORY/etesync.crt + ''} + ${optionalString (cfg.sslCertificateKey != null) '' + cp ${toString cfg.sslCertificateKey} $STATE_DIRECTORY/etesync.key + ''} + '' + ); + Restart = "on-failure"; + RestartSec = "30min 1s"; + }; + }; + }; + } |