1{
2 lib,
3 stdenv,
4 fetchurl,
5 erlang,
6 icu,
7 openssl,
8 spidermonkey_91,
9 python3,
10 nixosTests,
11}:
12
13stdenv.mkDerivation rec {
14 pname = "couchdb";
15 version = "3.5.0";
16
17 src = fetchurl {
18 url = "mirror://apache/couchdb/source/${version}/apache-${pname}-${version}.tar.gz";
19 hash = "sha256-api5CpqYC77yw1tJlqjnGi8a5SJ1RshfBMQ2EBvfeL8=";
20 };
21
22 postPatch = ''
23 substituteInPlace src/couch/rebar.config.script --replace '/usr/include/mozjs-91' "${spidermonkey_91.dev}/include/mozjs-91"
24 substituteInPlace configure --replace '/usr/include/''${SM_HEADERS}' "${spidermonkey_91.dev}/include/mozjs-91"
25 patchShebangs bin/rebar
26 ''
27 + lib.optionalString stdenv.hostPlatform.isDarwin ''
28 # LTO with Clang produces LLVM bitcode, which causes linking to fail quietly.
29 # (There are warnings, but no hard errors, and it produces an empty dylib.)
30 substituteInPlace src/jiffy/rebar.config.script --replace '"-flto"' '""'
31 '';
32
33 nativeBuildInputs = [
34 erlang
35 ];
36
37 buildInputs = [
38 icu
39 openssl
40 spidermonkey_91
41 (python3.withPackages (ps: with ps; [ requests ]))
42 ];
43
44 dontAddPrefix = "True";
45
46 configureFlags = [
47 "--spidermonkey-version=91"
48 ];
49
50 buildFlags = [
51 "release"
52 ];
53
54 installPhase = ''
55 runHook preInstall
56 mkdir -p $out
57 cp -r rel/couchdb/* $out
58 runHook postInstall
59 '';
60
61 passthru.tests = {
62 inherit (nixosTests) couchdb;
63 };
64
65 meta = with lib; {
66 description = "Database that uses JSON for documents, JavaScript for MapReduce queries, and regular HTTP for an API";
67 homepage = "https://couchdb.apache.org";
68 license = licenses.asl20;
69 platforms = platforms.all;
70 maintainers = with maintainers; [ lostnet ];
71 };
72}