2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
93 lines
2.7 KiB
Nix
93 lines
2.7 KiB
Nix
{ 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 = lib.mdDoc "The server host address.";
|
|
};
|
|
|
|
port = mkOption {
|
|
type = types.port;
|
|
default = 37358;
|
|
description = lib.mdDoc "The server host port.";
|
|
};
|
|
|
|
apiUrl = mkOption {
|
|
type = types.str;
|
|
default = "https://api.etesync.com/";
|
|
description = lib.mdDoc "The url to the etesync API.";
|
|
};
|
|
|
|
openFirewall = mkOption {
|
|
default = false;
|
|
type = types.bool;
|
|
description = lib.mdDoc "Whether to open the firewall for the specified port.";
|
|
};
|
|
|
|
sslCertificate = mkOption {
|
|
type = types.nullOr types.path;
|
|
default = null;
|
|
example = "/var/etesync.crt";
|
|
description = lib.mdDoc ''
|
|
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 = lib.mdDoc ''
|
|
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";
|
|
};
|
|
};
|
|
};
|
|
}
|