From e16a0988bc18be3997f5c475f373a8ac127d3fa0 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Tue, 25 Jul 2017 09:01:08 +0200 Subject: [PATCH] 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. --- nixos/doc/manual/release-notes/rl-1709.xml | 3 + .../modules/services/networking/radicale.nix | 40 ++++++--- nixos/release.nix | 1 + nixos/tests/radicale.nix | 83 +++++-------------- pkgs/servers/radicale/1.x.nix | 34 ++++++++ pkgs/servers/radicale/default.nix | 32 ++++--- pkgs/top-level/all-packages.nix | 5 +- 7 files changed, 112 insertions(+), 86 deletions(-) create mode 100644 pkgs/servers/radicale/1.x.nix diff --git a/nixos/doc/manual/release-notes/rl-1709.xml b/nixos/doc/manual/release-notes/rl-1709.xml index a32f9963d1c..0850189f634 100644 --- a/nixos/doc/manual/release-notes/rl-1709.xml +++ b/nixos/doc/manual/release-notes/rl-1709.xml @@ -101,6 +101,9 @@ rmdir /var/lib/ipfs/.ipfs The mysql default dataDir has changed from /var/mysql to /var/lib/mysql. + + Radicale's default package has changed from 1.x to 2.x. Instructions to migrate can be found here . It is also possible to use the newer version by setting the package to radicale2, which is done automatically when stateVersion is 17.09 or higher. + diff --git a/nixos/modules/services/networking/radicale.nix b/nixos/modules/services/networking/radicale.nix index ef860e7e5df..f1b8edf4371 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 + system.stateVersion < 17.09 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 ]; } diff --git a/nixos/release.nix b/nixos/release.nix index 9604da5a4d7..7ee0c6064d0 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -297,6 +297,7 @@ in rec { tests.pumpio = callTest tests/pump.io.nix {}; # tests.quagga = callTest tests/quagga.nix {}; tests.quake3 = callTest tests/quake3.nix {}; + tests.radicale = callTest tests/radicale.nix {}; tests.runInMachine = callTest tests/run-in-machine.nix {}; tests.samba = callTest tests/samba.nix {}; tests.sddm = callSubTests tests/sddm.nix {}; diff --git a/nixos/tests/radicale.nix b/nixos/tests/radicale.nix index 4c2ed8456dd..bec86d2cb28 100644 --- a/nixos/tests/radicale.nix +++ b/nixos/tests/radicale.nix @@ -1,80 +1,39 @@ let - port = 5232; - radicaleOverlay = self: super: { - radicale = super.radicale.overrideAttrs (oldAttrs: { - propagatedBuildInputs = with self.pythonPackages; - (oldAttrs.propagatedBuildInputs or []) ++ [ - passlib - ]; - }); - }; - common = { config, pkgs, ...}: { + user = "someuser"; + password = "some_password"; + port = builtins.toString 5232; +in + import ./make-test.nix ({ pkgs, lib, ... }: { + name = "radicale"; + meta.maintainers = with lib.maintainers; [ aneeshusa infinisil ]; + + machine = { services.radicale = { enable = true; - config = let home = config.users.extraUsers.radicale.home; in '' - [server] - hosts = 127.0.0.1:${builtins.toString port} - daemon = False - [encoding] - [well-known] + config = '' [auth] type = htpasswd htpasswd_filename = /etc/radicale/htpasswd htpasswd_encryption = bcrypt - [git] - [rights] + [storage] - type = filesystem - filesystem_folder = ${home}/collections + filesystem_folder = /tmp/collections + [logging] - [headers] + debug = True ''; }; # WARNING: DON'T DO THIS IN PRODUCTION! # This puts secrets (albeit hashed) directly into the Nix store for ease of testing. - environment.etc."radicale/htpasswd".source = with pkgs; let - py = python.withPackages(ps: with ps; [ passlib ]); - in runCommand "htpasswd" {} '' - ${py}/bin/python -c " -from passlib.apache import HtpasswdFile -ht = HtpasswdFile( - '$out', - new=True, - default_scheme='bcrypt' -) -ht.set_password('someuser', 'really_secret_password') -ht.save() -" + environment.etc."radicale/htpasswd".source = pkgs.runCommand "htpasswd" {} '' + ${pkgs.apacheHttpd}/bin/htpasswd -bcB "$out" ${user} ${password} ''; }; - -in import ./make-test.nix ({ lib, ... }: { - name = "radicale"; - meta.maintainers = with lib.maintainers; [ aneeshusa ]; - - # Test radicale with bcrypt-based htpasswd authentication - nodes = { - py2 = { config, pkgs, ... }@args: (common args) // { - nixpkgs.overlays = [ - radicaleOverlay - ]; - }; - py3 = { config, pkgs, ... }@args: (common args) // { - nixpkgs.overlays = [ - (self: super: { - python = self.python3; - pythonPackages = self.python3.pkgs; - }) - radicaleOverlay - ]; - }; - }; - + + # This tests whether the web interface is accessible to an authenticated user testScript = '' - for my $machine ($py2, $py3) { - $machine->waitForUnit('radicale.service'); - $machine->waitForOpenPort(${builtins.toString port}); - $machine->succeed('curl -s http://someuser:really_secret_password@127.0.0.1:${builtins.toString port}/someuser/calendar.ics/'); - } + $machine->waitForUnit('radicale.service'); + $machine->waitForOpenPort(${port}); + $machine->succeed('curl --fail http://${user}:${password}@localhost:${port}/.web/'); ''; }) diff --git a/pkgs/servers/radicale/1.x.nix b/pkgs/servers/radicale/1.x.nix new file mode 100644 index 00000000000..13db868845a --- /dev/null +++ b/pkgs/servers/radicale/1.x.nix @@ -0,0 +1,34 @@ +{ stdenv, fetchurl, pythonPackages }: + +pythonPackages.buildPythonApplication rec { + name = "radicale-${version}"; + version = "1.1.6"; + + src = fetchurl { + url = "mirror://pypi/R/Radicale/Radicale-${version}.tar.gz"; + sha256 = "0ay90nj6fmr2aq8imi0mbjl4m2rzq7a83ikj8qs9gxsylj71j1y0"; + }; + + propagatedBuildInputs = stdenv.lib.optionals (!pythonPackages.isPy3k) [ + pythonPackages.flup + pythonPackages.ldap + pythonPackages.sqlalchemy + ]; + + doCheck = !pythonPackages.isPy3k; + + meta = with stdenv.lib; { + homepage = http://www.radicale.org/; + description = "CalDAV CardDAV server"; + longDescription = '' + The Radicale Project is a complete CalDAV (calendar) and CardDAV + (contact) server solution. Calendars and address books are available for + both local and remote access, possibly limited through authentication + policies. They can be viewed and edited by calendar and contact clients + on mobile phones or computers. + ''; + license = licenses.gpl3Plus; + platforms = platforms.all; + maintainers = with maintainers; [ edwtjo pSub aneeshusa ]; + }; +} diff --git a/pkgs/servers/radicale/default.nix b/pkgs/servers/radicale/default.nix index b6d61e29395..ee38783a899 100644 --- a/pkgs/servers/radicale/default.nix +++ b/pkgs/servers/radicale/default.nix @@ -1,21 +1,27 @@ -{ stdenv, fetchurl, pythonPackages }: +{ stdenv, fetchFromGitHub, python3Packages }: -pythonPackages.buildPythonApplication rec { +let + version = "2.1.2"; + sha256 = "0gmbnvm17j0ilcnci1k2jh0vkbz5g8xlk9lgia5mlx790048hlm8"; +in + +python3Packages.buildPythonApplication { name = "radicale-${version}"; - version = "1.1.4"; + inherit version; - src = fetchurl { - url = "mirror://pypi/R/Radicale/Radicale-${version}.tar.gz"; - sha256 = "17p0hayyw30pfb81xqvd7jhjm6yrk2dnbgvqagx1nqdsr89ar0ss"; + src = fetchFromGitHub { + owner = "Kozea"; + repo = "Radicale"; + rev = version; + inherit sha256; }; - propagatedBuildInputs = stdenv.lib.optionals (!pythonPackages.isPy3k) [ - pythonPackages.flup - pythonPackages.ldap - pythonPackages.sqlalchemy - ]; + doCheck = false; - doCheck = !pythonPackages.isPy3k; + propagatedBuildInputs = with python3Packages; [ + vobject + passlib + ]; meta = with stdenv.lib; { homepage = http://www.radicale.org/; @@ -29,6 +35,6 @@ pythonPackages.buildPythonApplication rec { ''; license = licenses.gpl3Plus; platforms = platforms.all; - maintainers = with maintainers; [ edwtjo pSub aneeshusa ]; + maintainers = with maintainers; [ edwtjo pSub aneeshusa infinisil ]; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f6ae62db18d..eebda89ece6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11468,7 +11468,10 @@ with pkgs; inherit (darwin.apple_sdk.frameworks) AppKit Carbon Cocoa; }; - radicale = callPackage ../servers/radicale { }; + radicale1 = callPackage ../servers/radicale/1.x.nix { }; + radicale2 = callPackage ../servers/radicale/default.nix { }; + + radicale = radicale2; rake = callPackage ../development/tools/build-managers/rake { };