git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #84246 from lostnet/couchdbpr

couchdb: add support for version 3.0.0

commit607f5a6755dddb0b6ecce5bb227234db1a527501 authorDamien Cassou <damien@cassou.me> dateFri 11 Sep 2020, 17:47 (6 years ago) parent5e0112b0ef1be0
5 files changed+124−30
maintainers/maintainer-list.nix+6 nixos/modules/services/databases/couchdb.nix+24−1 nixos/tests/couchdb.nix+51−29 pkgs/servers/http/couchdb/3.nix+38 pkgs/top-level/all-packages.nix+5
maintainers/maintainer-list.nix+6
@@ -4924,6 +4924,12 @@
49244924 githubId = 1202012;
49254925 name = "Ignat Loskutov";
49264926 };
4927+ lostnet = {
4928+ email = "lost.networking@gmail.com";
4929+ github = "lostnet";
4930+ githubId = 1422781;
4931+ name = "Will Young";
4932+ };
49274933 louisdk1 = {
49284934 email = "louis@louis.dk";
49294935 github = "louisdk1";
nixos/modules/services/databases/couchdb.nix+24−1
@@ -11,7 +11,13 @@ let
1111 database_dir = ${cfg.databaseDir}
1212 uri_file = ${cfg.uriFile}
1313 view_index_dir = ${cfg.viewIndexDir}
14− '' + (if useVersion2 then
14+ '' + (if cfg.adminPass != null then
15+ ''
16+ [admins]
17+ ${cfg.adminUser} = ${cfg.adminPass}
18+ '' else
19+ ''
20+ '') + (if useVersion2 then
1521 ''
1622 [chttpd]
1723 '' else
@@ -54,6 +60,23 @@ in {
5460 '';
5561 };
5662
63+ adminUser = mkOption {
64+ type = types.str;
65+ default = "admin";
66+ description = ''
67+ Couchdb (i.e. fauxton) account with permission for all dbs and
68+ tasks.
69+ '';
70+ };
71+
72+ adminPass = mkOption {
73+ type = types.nullOr types.str;
74+ default = null;
75+ description = ''
76+ Couchdb (i.e. fauxton) account with permission for all dbs and
77+ tasks.
78+ '';
79+ };
5780
5881 user = mkOption {
5982 type = types.str;
nixos/tests/couchdb.nix+51−29
@@ -1,4 +1,19 @@
1−import ./make-test-python.nix ({ pkgs, lib, ...}:
1+let
2+
3+ makeNode = couchpkg: user: passwd:
4+ { pkgs, ... } :
5+
6+ { environment.systemPackages = with pkgs; [ jq ];
7+ services.couchdb.enable = true;
8+ services.couchdb.package = couchpkg;
9+ services.couchdb.adminUser = user;
10+ services.couchdb.adminPass = passwd;
11+ };
12+ testuser = "testadmin";
13+ testpass = "cowabunga";
14+ testlogin = "${testuser}:${testpass}@";
15+
16+in import ./make-test-python.nix ({ pkgs, lib, ...}:
217
318with lib;
419
@@ -9,26 +24,15 @@ with lib;
924 };
1025
1126 nodes = {
12− couchdb1 =
13− { pkgs, ... }:
14−
15− { environment.systemPackages = with pkgs; [ jq ];
16− services.couchdb.enable = true;
17− };
18−
19− couchdb2 =
20− { pkgs, ... }:
21−
22− { environment.systemPackages = with pkgs; [ jq ];
23− services.couchdb.enable = true;
24− services.couchdb.package = pkgs.couchdb2;
25− };
27+ couchdb1 = makeNode pkgs.couchdb testuser testpass;
28+ couchdb2 = makeNode pkgs.couchdb2 testuser testpass;
29+ couchdb3 = makeNode pkgs.couchdb3 testuser testpass;
2630 };
2731
2832 testScript = let
29− curlJqCheck = action: path: jqexpr: result:
33+ curlJqCheck = login: action: path: jqexpr: result:
3034 pkgs.writeScript "curl-jq-check-${action}-${path}.sh" ''
31− RESULT=$(curl -X ${action} http://127.0.0.1:5984/${path} | jq -r '${jqexpr}')
35+ RESULT=$(curl -X ${action} http://${login}127.0.0.1:5984/${path} | jq -r '${jqexpr}')
3236 echo $RESULT >&2
3337 if [ "$RESULT" != "${result}" ]; then
3438 exit 1
@@ -39,38 +43,56 @@ with lib;
3943
4044 couchdb1.wait_for_unit("couchdb.service")
4145 couchdb1.wait_until_succeeds(
42− "${curlJqCheck "GET" "" ".couchdb" "Welcome"}"
46+ "${curlJqCheck "" "GET" "" ".couchdb" "Welcome"}"
4347 )
4448 couchdb1.wait_until_succeeds(
45− "${curlJqCheck "GET" "_all_dbs" ". | length" "2"}"
49+ "${curlJqCheck "" "GET" "_all_dbs" ". | length" "2"}"
4650 )
47− couchdb1.succeed("${curlJqCheck "PUT" "foo" ".ok" "true"}")
51+ couchdb1.succeed("${curlJqCheck testlogin "PUT" "foo" ".ok" "true"}")
4852 couchdb1.succeed(
49− "${curlJqCheck "GET" "_all_dbs" ". | length" "3"}"
53+ "${curlJqCheck "" "GET" "_all_dbs" ". | length" "3"}"
5054 )
5155 couchdb1.succeed(
52− "${curlJqCheck "DELETE" "foo" ".ok" "true"}"
56+ "${curlJqCheck testlogin "DELETE" "foo" ".ok" "true"}"
5357 )
5458 couchdb1.succeed(
55− "${curlJqCheck "GET" "_all_dbs" ". | length" "2"}"
59+ "${curlJqCheck "" "GET" "_all_dbs" ". | length" "2"}"
5660 )
5761
5862 couchdb2.wait_for_unit("couchdb.service")
5963 couchdb2.wait_until_succeeds(
60− "${curlJqCheck "GET" "" ".couchdb" "Welcome"}"
64+ "${curlJqCheck "" "GET" "" ".couchdb" "Welcome"}"
6165 )
6266 couchdb2.wait_until_succeeds(
63− "${curlJqCheck "GET" "_all_dbs" ". | length" "0"}"
67+ "${curlJqCheck "" "GET" "_all_dbs" ". | length" "0"}"
6468 )
65− couchdb2.succeed("${curlJqCheck "PUT" "foo" ".ok" "true"}")
69+ couchdb2.succeed("${curlJqCheck testlogin "PUT" "foo" ".ok" "true"}")
6670 couchdb2.succeed(
67− "${curlJqCheck "GET" "_all_dbs" ". | length" "1"}"
71+ "${curlJqCheck "" "GET" "_all_dbs" ". | length" "1"}"
6872 )
6973 couchdb2.succeed(
70− "${curlJqCheck "DELETE" "foo" ".ok" "true"}"
74+ "${curlJqCheck testlogin "DELETE" "foo" ".ok" "true"}"
7175 )
7276 couchdb2.succeed(
73− "${curlJqCheck "GET" "_all_dbs" ". | length" "0"}"
77+ "${curlJqCheck "" "GET" "_all_dbs" ". | length" "0"}"
78+ )
79+
80+ couchdb3.wait_for_unit("couchdb.service")
81+ couchdb3.wait_until_succeeds(
82+ "${curlJqCheck testlogin "GET" "" ".couchdb" "Welcome"}"
83+ )
84+ couchdb3.wait_until_succeeds(
85+ "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "0"}"
86+ )
87+ couchdb3.succeed("${curlJqCheck testlogin "PUT" "foo" ".ok" "true"}")
88+ couchdb3.succeed(
89+ "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "1"}"
90+ )
91+ couchdb3.succeed(
92+ "${curlJqCheck testlogin "DELETE" "foo" ".ok" "true"}"
93+ )
94+ couchdb3.succeed(
95+ "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "0"}"
7496 )
7597 '';
7698})
pkgs/servers/http/couchdb/3.nixnew file+38
@@ -0,0 +1,38 @@
1+{ stdenv, fetchurl, erlang, icu, openssl, spidermonkey
2+, coreutils, bash, makeWrapper, python3 }:
3+
4+stdenv.mkDerivation rec {
5+ pname = "couchdb";
6+ version = "3.1.0";
7+
8+
9+ # when updating this, please consider bumping the erlang/OTP version
10+ # in all-packages.nix
11+ src = fetchurl {
12+ url = "mirror://apache/couchdb/source/${version}/apache-${pname}-${version}.tar.gz";
13+ sha256 = "1vgqj3zsrkdqgnwzji3mqkapnfd6kq466f5xnya0fvzzl6bcfrs8";
14+ };
15+
16+ buildInputs = [ erlang icu openssl spidermonkey (python3.withPackages(ps: with ps; [ requests ]))];
17+ postPatch = ''
18+ substituteInPlace src/couch/rebar.config.script --replace '/usr/include/mozjs-68' "${spidermonkey.dev}/include/mozjs-68"
19+ patchShebangs bin/rebar
20+ '';
21+
22+ dontAddPrefix= "True";
23+ configureFlags = ["--spidermonkey-version=68"];
24+ buildFlags = ["release"];
25+
26+ installPhase = ''
27+ mkdir -p $out
28+ cp -r rel/couchdb/* $out
29+ '';
30+
31+ meta = with stdenv.lib; {
32+ description = "A database that uses JSON for documents, JavaScript for MapReduce queries, and regular HTTP for an API";
33+ homepage = "http://couchdb.apache.org";
34+ license = licenses.asl20;
35+ platforms = platforms.all;
36+ maintainers = with maintainers; [ lostnet ];
37+ };
38+}
pkgs/top-level/all-packages.nix+5
@@ -16260,6 +16260,11 @@ in
1626016260 erlang = erlangR21;
1626116261 };
1626216262
16263+ couchdb3 = callPackage ../servers/http/couchdb/3.nix {
16264+ spidermonkey = spidermonkey_68;
16265+ erlang = erlangR22;
16266+ };
16267+
1626316268 couchpotato = callPackage ../servers/couchpotato {};
1626416269
1626516270 dex-oidc = callPackage ../servers/dex { };