diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 882ab0f7e..003ac4ea2 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -184,6 +184,8 @@ /modules/services/emacs.nix @tadfisher +/modules/services/etesync-dav.nix @Valodim + /modules/services/flameshot.nix @moredhel /modules/services/fluidsynth.nix @Valodim diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 5c570db0c..9a5a27d7b 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1946,7 +1946,7 @@ in A new module is available: 'programs.lazygit'. ''; } - + { time = "2021-04-27T00:00:00+00:00"; message = '' @@ -1954,6 +1954,13 @@ in ''; } + { + time = "2021-05-06T20:47:37+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.etesync-dav' + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index f3c29c86d..e6e178a38 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -151,6 +151,7 @@ let (loadModule ./services/dunst.nix { }) (loadModule ./services/dwm-status.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/emacs.nix { condition = hostPlatform.isLinux; }) + (loadModule ./services/etesync-dav.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/flameshot.nix { }) (loadModule ./services/fluidsynth.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/redshift-gammastep/gammastep.nix { condition = hostPlatform.isLinux; }) diff --git a/modules/services/etesync-dav.nix b/modules/services/etesync-dav.nix new file mode 100644 index 000000000..63ef6770e --- /dev/null +++ b/modules/services/etesync-dav.nix @@ -0,0 +1,62 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.etesync-dav; + + toEnvironmentCfg = vars: + (concatStringsSep " " + (mapAttrsToList (k: v: "${k}=${escapeShellArg v}") vars)); + +in { + meta.maintainers = [ maintainers.valodim ]; + + options.services.etesync-dav = { + enable = mkEnableOption "etesync-dav"; + + package = mkOption { + type = types.package; + default = pkgs.etesync-dav; + defaultText = "pkgs.etesync-dav"; + description = "The etesync-dav derivation to use."; + }; + + serverUrl = mkOption { + type = types.str; + default = "https://api.etesync.com/"; + description = "The URL to the etesync server."; + }; + + settings = mkOption { + type = types.attrsOf (types.oneOf [ types.str types.int ]); + default = { }; + example = literalExample '' + { + ETESYNC_LISTEN_ADDRESS = "localhost"; + ETESYNC_LISTEN_PORT = 37385; + } + ''; + description = '' + Settings for etesync-dav, passed as environment variables. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ cfg.package ]; + + systemd.user.services.etesync-dav = { + Unit = { Description = "etesync-dav"; }; + + Service = { + ExecStart = "${cfg.package}/bin/etesync-dav"; + Environment = + toEnvironmentCfg ({ ETESYNC_URL = cfg.serverUrl; } // cfg.settings); + }; + + Install = { WantedBy = [ "default.target" ]; }; + }; + }; +}