about summary refs log tree commit diff
path: root/nixos/modules/services/networking/radicale.nix
diff options
context:
space:
mode:
authorSilvan Mosberger <infinisil@icloud.com>2017-07-25 09:01:08 +0200
committerSilvan Mosberger <infinisil@icloud.com>2017-08-13 17:23:43 +0200
commite16a0988bc18be3997f5c475f373a8ac127d3fa0 (patch)
tree5d3acb65e70d4a5e36d04901f4296bd78ba29add /nixos/modules/services/networking/radicale.nix
parent5bc183ebf868b32b599692a3b651a39d8a97dee3 (diff)
downloadnixlib-e16a0988bc18be3997f5c475f373a8ac127d3fa0.tar
nixlib-e16a0988bc18be3997f5c475f373a8ac127d3fa0.tar.gz
nixlib-e16a0988bc18be3997f5c475f373a8ac127d3fa0.tar.bz2
nixlib-e16a0988bc18be3997f5c475f373a8ac127d3fa0.tar.lz
nixlib-e16a0988bc18be3997f5c475f373a8ac127d3fa0.tar.xz
nixlib-e16a0988bc18be3997f5c475f373a8ac127d3fa0.tar.zst
nixlib-e16a0988bc18be3997f5c475f373a8ac127d3fa0.zip
radicale: 1.1.4 -> 2.1.2
This commit readds and updates the 1.x package from 1.1.4 to 1.1.6 which
also includes the needed command for migrating to 2.x

The module is adjusted to the version change, defaulting to radicale2 if
stateVersion >= 17.09 and radicale1 otherwise. It also now uses
ExecStart instead of the script service attribute. Some missing dots at
the end of sentences were also added.

I added a paragraph in the release notes on how to update to a newer
version.
Diffstat (limited to 'nixos/modules/services/networking/radicale.nix')
-rw-r--r--nixos/modules/services/networking/radicale.nix40
1 files changed, 30 insertions, 10 deletions
diff --git a/nixos/modules/services/networking/radicale.nix b/nixos/modules/services/networking/radicale.nix
index ef860e7e5df4..f1b8edf43713 100644
--- a/nixos/modules/services/networking/radicale.nix
+++ b/nixos/modules/services/networking/radicale.nix
@@ -1,4 +1,4 @@
-{config, lib, pkgs, ...}:
+{ config, lib, pkgs, ... }:
 
 with lib;
 
@@ -8,17 +8,35 @@ let
 
   confFile = pkgs.writeText "radicale.conf" cfg.config;
 
+  # This enables us to default to version 2 while still not breaking configurations of people with version 1
+  defaultPackage = if versionAtLeast "17.09" config.system.stateVersion then {
+    pkg = pkgs.radicale2;
+    text = "pkgs.radicale2";
+  } else {
+    pkg = pkgs.radicale1;
+    text = "pkgs.radicale1";
+  };
 in
 
 {
 
   options = {
-
     services.radicale.enable = mkOption {
       type = types.bool;
       default = false;
       description = ''
-          Enable Radicale CalDAV and CardDAV server
+          Enable Radicale CalDAV and CardDAV server.
+      '';
+    };
+
+    services.radicale.package = mkOption {
+      type = types.package;
+      default = defaultPackage.pkg;
+      defaultText = defaultPackage.text;
+      description = ''
+        Radicale package to use. This defaults to version 1.x if
+        <literal>system.stateVersion &lt; 17.09</literal> and version 2.x
+        otherwise.
       '';
     };
 
@@ -27,13 +45,13 @@ in
       default = "";
       description = ''
         Radicale configuration, this will set the service
-        configuration file
+        configuration file.
       '';
-      };
+    };
   };
 
   config = mkIf cfg.enable {
-    environment.systemPackages = [ pkgs.radicale ];
+    environment.systemPackages = [ cfg.package ];
 
     users.extraUsers = singleton
       { name = "radicale";
@@ -52,11 +70,13 @@ in
       description = "A Simple Calendar and Contact Server";
       after = [ "network.target" ];
       wantedBy = [ "multi-user.target" ];
-      script = "${pkgs.radicale}/bin/radicale -C ${confFile} -f";
-      serviceConfig.User = "radicale";
-      serviceConfig.Group = "radicale";
+      serviceConfig = {
+        ExecStart = "${cfg.package}/bin/radicale -C ${confFile} -f";
+        User = "radicale";
+        Group = "radicale";
+      };
     };
   };
 
-  meta.maintainers = with lib.maintainers; [ aneeshusa ];
+  meta.maintainers = with lib.maintainers; [ aneeshusa infinisil ];
 }