From 669f5819e20a4d21b6054b64e079ac2a555d4b1c Mon Sep 17 00:00:00 2001 From: Aneesh Agrawal Date: Wed, 1 Feb 2017 00:46:19 -0500 Subject: [PATCH 1/7] bcrypt: add required dependency on `six` --- pkgs/development/python-modules/bcrypt.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/bcrypt.nix b/pkgs/development/python-modules/bcrypt.nix index 94f04880c8e..8a099983521 100644 --- a/pkgs/development/python-modules/bcrypt.nix +++ b/pkgs/development/python-modules/bcrypt.nix @@ -1,5 +1,5 @@ { stdenv, buildPythonPackage, isPyPy, fetchurl -, cffi, pycparser, mock, pytest, py }: +, cffi, pycparser, mock, pytest, py, six }: with stdenv.lib; @@ -12,7 +12,7 @@ buildPythonPackage rec { sha256 = "1al54xafv1aharpb22yv5rjjc63fm60z3pn2shbiq48ah9f1fvil"; }; buildInputs = [ pycparser mock pytest py ]; - propagatedBuildInputs = optional (!isPyPy) cffi; + propagatedBuildInputs = [ six ] ++ optional (!isPyPy) cffi; meta = { maintainers = with maintainers; [ domenkozar ]; From 0168e48186bd5bbb5915bf3c591179cedd28802d Mon Sep 17 00:00:00 2001 From: Aneesh Agrawal Date: Tue, 31 Jan 2017 23:43:11 -0500 Subject: [PATCH 2/7] passlib: switch from insecure pybcrypt to bcrypt Also propagated bcrypt so that downstream dependencies are able to use the bcrypt backend. --- pkgs/top-level/python-packages.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 74b00ad6ff2..8201d2bb43e 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -8774,7 +8774,8 @@ in { sha256 = "1z27wdxs5rj5xhhqfzvzn3yg682irkxw6dcs5jj7mcf97psk8gd8"; }; - buildInputs = with self; [ nose pybcrypt]; + buildInputs = with self; [ nose ]; + propagatedBuildInputs = with self; [ bcrypt ]; meta = { description = "A password hashing library for Python"; From 189479a4ba67fa935a1d407f4a4b87837fc53456 Mon Sep 17 00:00:00 2001 From: Aneesh Agrawal Date: Thu, 2 Feb 2017 17:59:39 -0500 Subject: [PATCH 3/7] radicale: Add NixOS test with Python 2 Includes testing bcrypt authentication. --- nixos/tests/radicale.nix | 70 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 nixos/tests/radicale.nix diff --git a/nixos/tests/radicale.nix b/nixos/tests/radicale.nix new file mode 100644 index 00000000000..ea834d2768d --- /dev/null +++ b/nixos/tests/radicale.nix @@ -0,0 +1,70 @@ +let + port = 5232; + radicaleOverlay = self: super: { + radicale = super.radicale.overrideAttrs (oldAttrs: { + propagatedBuildInputs = with self.pythonPackages; + (oldAttrs.propagatedBuildInputs or []) ++ [ + passlib + ]; + }); + }; + common = { config, pkgs, ...}: { + 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] + [auth] + type = htpasswd + htpasswd_filename = /etc/radicale/htpasswd + htpasswd_encryption = bcrypt + [git] + [rights] + [storage] + type = filesystem + filesystem_folder = ${home}/collections + [logging] + [headers] + ''; + }; + # 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() +" + ''; + }; + +in import ./make-test.nix { + name = "radicale"; + + # Test radicale with bcrypt-based htpasswd authentication + nodes = { + py2 = { config, pkgs, ... }@args: (common args) // { + nixpkgs.overlays = [ + radicaleOverlay + ]; + }; + }; + + testScript = '' + for my $machine ($py2) { + $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/'); + } + ''; +} From 8ce337fd965d6089178b9198e235747f82bf5844 Mon Sep 17 00:00:00 2001 From: Aneesh Agrawal Date: Tue, 31 Jan 2017 23:16:13 -0500 Subject: [PATCH 4/7] radicale: Remove optional deps on Python 3 None of these dependencies is required for radicale to function, and flup in particular prevents usage with Python 3. --- pkgs/servers/radicale/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/servers/radicale/default.nix b/pkgs/servers/radicale/default.nix index 47bdad75343..4e0ff0c23f6 100644 --- a/pkgs/servers/radicale/default.nix +++ b/pkgs/servers/radicale/default.nix @@ -9,7 +9,7 @@ pythonPackages.buildPythonApplication rec { sha256 = "1c5lv8qca21mndkx350wxv34qypqh6gb4rhzms4anr642clq3jg2"; }; - propagatedBuildInputs = [ + propagatedBuildInputs = stdenv.lib.optionals (!pythonPackages.isPy3k) [ pythonPackages.flup pythonPackages.ldap pythonPackages.sqlalchemy From 9821f82d7cff4bd56b6b4156628b6ed6adf4fc1f Mon Sep 17 00:00:00 2001 From: Aneesh Agrawal Date: Sat, 11 Feb 2017 15:34:46 -0500 Subject: [PATCH 5/7] radicale: Disable tests on Python 3 --- pkgs/servers/radicale/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/servers/radicale/default.nix b/pkgs/servers/radicale/default.nix index 4e0ff0c23f6..b7282a36baf 100644 --- a/pkgs/servers/radicale/default.nix +++ b/pkgs/servers/radicale/default.nix @@ -15,7 +15,7 @@ pythonPackages.buildPythonApplication rec { pythonPackages.sqlalchemy ]; - doCheck = true; + doCheck = !pythonPackages.isPy3k; meta = with stdenv.lib; { homepage = http://www.radicale.org/; From a3143b18e00f18a7fff1cb6181d4feaeffd24142 Mon Sep 17 00:00:00 2001 From: Aneesh Agrawal Date: Sat, 11 Feb 2017 15:28:38 -0500 Subject: [PATCH 6/7] radicale: Also run NixOS test on Python 3 --- nixos/tests/radicale.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nixos/tests/radicale.nix b/nixos/tests/radicale.nix index ea834d2768d..f0d46d48a75 100644 --- a/nixos/tests/radicale.nix +++ b/nixos/tests/radicale.nix @@ -58,10 +58,19 @@ in import ./make-test.nix { radicaleOverlay ]; }; + py3 = { config, pkgs, ... }@args: (common args) // { + nixpkgs.overlays = [ + (self: super: { + python = self.python3; + pythonPackages = self.python3.pkgs; + }) + radicaleOverlay + ]; + }; }; testScript = '' - for my $machine ($py2) { + 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/'); From 8f4d778509271c8cd1e1b8ab1f01c2de038cc7ba Mon Sep 17 00:00:00 2001 From: Aneesh Agrawal Date: Mon, 20 Mar 2017 12:13:27 -0400 Subject: [PATCH 7/7] radicale: Add aneeshusa as maintainer --- nixos/modules/services/networking/radicale.nix | 2 ++ nixos/tests/radicale.nix | 5 +++-- pkgs/servers/radicale/default.nix | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/networking/radicale.nix b/nixos/modules/services/networking/radicale.nix index f9300fdabc5..ef860e7e5df 100644 --- a/nixos/modules/services/networking/radicale.nix +++ b/nixos/modules/services/networking/radicale.nix @@ -57,4 +57,6 @@ in serviceConfig.Group = "radicale"; }; }; + + meta.maintainers = with lib.maintainers; [ aneeshusa ]; } diff --git a/nixos/tests/radicale.nix b/nixos/tests/radicale.nix index f0d46d48a75..4c2ed8456dd 100644 --- a/nixos/tests/radicale.nix +++ b/nixos/tests/radicale.nix @@ -48,8 +48,9 @@ ht.save() ''; }; -in import ./make-test.nix { +in import ./make-test.nix ({ lib, ... }: { name = "radicale"; + meta.maintainers = with lib.maintainers; [ aneeshusa ]; # Test radicale with bcrypt-based htpasswd authentication nodes = { @@ -76,4 +77,4 @@ in import ./make-test.nix { $machine->succeed('curl -s http://someuser:really_secret_password@127.0.0.1:${builtins.toString port}/someuser/calendar.ics/'); } ''; -} +}) diff --git a/pkgs/servers/radicale/default.nix b/pkgs/servers/radicale/default.nix index b7282a36baf..a701ad5d833 100644 --- a/pkgs/servers/radicale/default.nix +++ b/pkgs/servers/radicale/default.nix @@ -29,6 +29,6 @@ pythonPackages.buildPythonApplication rec { ''; license = licenses.gpl3Plus; platform = platforms.all; - maintainers = with maintainers; [ edwtjo pSub ]; + maintainers = with maintainers; [ edwtjo pSub aneeshusa ]; }; }