Merge pull request #29521 from aneeshusa/ease-radicale-upgrade

Ease radicale upgrade

authored by Franz Pletz and committed by GitHub 406c7a07 8a401881

+92 -16
+1 -1
nixos/doc/manual/release-notes/rl-1709.xml
··· 107 The <literal>mysql</literal> default <literal>dataDir</literal> has changed from <literal>/var/mysql</literal> to <literal>/var/lib/mysql</literal>. 108 </para> 109 <para> 110 - Radicale's default package has changed from 1.x to 2.x. Instructions to migrate can be found <link xlink:href="http://radicale.org/1to2/"> here </link>. It is also possible to use the newer version by setting the <literal>package</literal> to <literal>radicale2</literal>, which is done automatically when <literal>stateVersion</literal> is 17.09 or higher. 111 </para> 112 </listitem> 113 <listitem>
··· 107 The <literal>mysql</literal> default <literal>dataDir</literal> has changed from <literal>/var/mysql</literal> to <literal>/var/lib/mysql</literal>. 108 </para> 109 <para> 110 + Radicale's default package has changed from 1.x to 2.x. Instructions to migrate can be found <link xlink:href="http://radicale.org/1to2/"> here </link>. It is also possible to use the newer version by setting the <literal>package</literal> to <literal>radicale2</literal>, which is done automatically when <literal>stateVersion</literal> is 17.09 or higher. The <literal>extraArgs</literal> option has been added to allow passing the data migration arguments specified in the instructions; see the <filename xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/radicale.nix">radicale.nix</filename> NixOS test for an example migration. 111 </para> 112 </listitem> 113 <listitem>
+11 -1
nixos/modules/services/networking/radicale.nix
··· 48 configuration file. 49 ''; 50 }; 51 }; 52 53 config = mkIf cfg.enable { ··· 71 after = [ "network.target" ]; 72 wantedBy = [ "multi-user.target" ]; 73 serviceConfig = { 74 - ExecStart = "${cfg.package}/bin/radicale -C ${confFile} -f"; 75 User = "radicale"; 76 Group = "radicale"; 77 };
··· 48 configuration file. 49 ''; 50 }; 51 + 52 + services.radicale.extraArgs = mkOption { 53 + type = types.listOf types.string; 54 + default = []; 55 + description = "Extra arguments passed to the Radicale daemon."; 56 + }; 57 }; 58 59 config = mkIf cfg.enable { ··· 77 after = [ "network.target" ]; 78 wantedBy = [ "multi-user.target" ]; 79 serviceConfig = { 80 + ExecStart = concatStringsSep " " ([ 81 + "${cfg.package}/bin/radicale" "-C" confFile 82 + ] ++ ( 83 + map escapeShellArg cfg.extraArgs 84 + )); 85 User = "radicale"; 86 Group = "radicale"; 87 };
+78 -12
nixos/tests/radicale.nix
··· 2 user = "someuser"; 3 password = "some_password"; 4 port = builtins.toString 5232; 5 - in 6 - import ./make-test.nix ({ pkgs, lib, ... }: { 7 - name = "radicale"; 8 - meta.maintainers = with lib.maintainers; [ aneeshusa infinisil ]; 9 10 - machine = { 11 services.radicale = { 12 enable = true; 13 config = '' ··· 29 ${pkgs.apacheHttpd}/bin/htpasswd -bcB "$out" ${user} ${password} 30 ''; 31 }; 32 - 33 - # This tests whether the web interface is accessible to an authenticated user 34 - testScript = '' 35 - $machine->waitForUnit('radicale.service'); 36 - $machine->waitForOpenPort(${port}); 37 - $machine->succeed('curl --fail http://${user}:${password}@localhost:${port}/.web/'); 38 - ''; 39 })
··· 2 user = "someuser"; 3 password = "some_password"; 4 port = builtins.toString 5232; 5 6 + common = { pkgs, ... }: { 7 services.radicale = { 8 enable = true; 9 config = '' ··· 25 ${pkgs.apacheHttpd}/bin/htpasswd -bcB "$out" ${user} ${password} 26 ''; 27 }; 28 + 29 + in 30 + 31 + import ./make-test.nix ({ pkgs, lib, ... }@args: { 32 + name = "radicale"; 33 + meta.maintainers = with lib.maintainers; [ aneeshusa infinisil ]; 34 + 35 + nodes = rec { 36 + radicale = radicale1; # Make the test script read more nicely 37 + radicale1 = lib.recursiveUpdate (common args) { 38 + nixpkgs.overlays = [ 39 + (self: super: { 40 + radicale1 = super.radicale1.overrideAttrs (oldAttrs: { 41 + propagatedBuildInputs = with self.pythonPackages; 42 + (oldAttrs.propagatedBuildInputs or []) ++ [ passlib ]; 43 + }); 44 + }) 45 + ]; 46 + }; 47 + radicale1_export = lib.recursiveUpdate radicale1 { 48 + services.radicale.extraArgs = [ 49 + "--export-storage" "/tmp/collections-new" 50 + ]; 51 + }; 52 + radicale2_verify = lib.recursiveUpdate radicale2 { 53 + services.radicale.extraArgs = [ "--verify-storage" ]; 54 + }; 55 + radicale2 = lib.recursiveUpdate (common args) { 56 + system.stateVersion = "17.09"; 57 + }; 58 + }; 59 + 60 + # This tests whether the web interface is accessible to an authenticated user 61 + testScript = { nodes }: let 62 + switchToConfig = nodeName: let 63 + newSystem = nodes.${nodeName}.config.system.build.toplevel; 64 + in "${newSystem}/bin/switch-to-configuration test"; 65 + in '' 66 + # Check Radicale 1 functionality 67 + $radicale->succeed('${switchToConfig "radicale1"} >&2'); 68 + $radicale->waitForUnit('radicale.service'); 69 + $radicale->waitForOpenPort(${port}); 70 + $radicale->succeed('curl --fail http://${user}:${password}@localhost:${port}/someuser/calendar.ics/'); 71 + 72 + # Export data in Radicale 2 format 73 + $radicale->succeed('systemctl stop radicale'); 74 + $radicale->succeed('ls -al /tmp/collections'); 75 + $radicale->fail('ls -al /tmp/collections-new'); 76 + # Radicale exits immediately after exporting storage 77 + $radicale->succeed('${switchToConfig "radicale1_export"} >&2'); 78 + $radicale->waitUntilFails('systemctl status radicale'); 79 + $radicale->succeed('ls -al /tmp/collections'); 80 + $radicale->succeed('ls -al /tmp/collections-new'); 81 + 82 + # Verify data in Radicale 2 format 83 + $radicale->succeed('rm -r /tmp/collections/${user}'); 84 + $radicale->succeed('mv /tmp/collections-new/collection-root /tmp/collections'); 85 + $radicale->succeed('${switchToConfig "radicale2_verify"} >&2'); 86 + $radicale->waitUntilFails('systemctl status radicale'); 87 + my ($retcode, $logs) = $radicale->execute('journalctl -u radicale -n 5'); 88 + if ($retcode != 0 || index($logs, 'Verifying storage') == -1) { 89 + die "Radicale 2 didn't verify storage" 90 + } 91 + if (index($logs, 'failed') != -1 || index($logs, 'exception') != -1) { 92 + die "storage verification failed" 93 + } 94 + 95 + # Check Radicale 2 functionality 96 + $radicale->succeed('${switchToConfig "radicale2"} >&2'); 97 + $radicale->waitForUnit('radicale.service'); 98 + $radicale->waitForOpenPort(${port}); 99 + my ($retcode, $output) = $radicale->execute('curl --fail http://${user}:${password}@localhost:${port}/someuser/calendar.ics/'); 100 + if ($retcode != 0 || index($output, 'VCALENDAR') == -1) { 101 + die "Could not read calendar from Radicale 2" 102 + } 103 + $radicale->succeed('curl --fail http://${user}:${password}@localhost:${port}/.web/'); 104 + ''; 105 })
+2 -2
pkgs/servers/radicale/default.nix
··· 1 { stdenv, fetchFromGitHub, python3Packages }: 2 3 let 4 - version = "2.1.2"; 5 - sha256 = "0gmbnvm17j0ilcnci1k2jh0vkbz5g8xlk9lgia5mlx790048hlm8"; 6 in 7 8 python3Packages.buildPythonApplication {
··· 1 { stdenv, fetchFromGitHub, python3Packages }: 2 3 let 4 + version = "2.1.6"; 5 + sha256 = "1x76nvxjhjpagniyh075hqia4sl06972alnhi7628cjrq3pr4v9i"; 6 in 7 8 python3Packages.buildPythonApplication {