New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
couchdb: add support for version 2.0.0 #22897
Conversation
@timor, thanks for your PR! By analyzing the history of the files in this pull request, we identified @garbas, @domenkozar and @offlinehacker to be potential reviewers. |
@LnL7 ping |
@@ -4,20 +4,29 @@ with lib; | |||
|
|||
let | |||
cfg = config.services.couchdb; | |||
configFile = pkgs.writeText "couchdb.ini" | |||
useVersion2 = strings.hasPrefix "2" (builtins.parseDrvName cfg.package.name).version; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is versionOlder
and versionAtLeast
in lib. (https://github.com/NixOS/nixpkgs/blob/master/lib/strings.nix#L343-L363)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using versionAtLeast would include any later versions, not only 2.x builds. Is that a problem?
@@ -151,6 +160,9 @@ in { | |||
description = "CouchDB Server"; | |||
wantedBy = [ "multi-user.target" ]; | |||
|
|||
# erlang crashes without sh in path | |||
path = mkIf useVersion2 [ pkgs.bash ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to wrap the binary to have it in path?
@@ -170,11 +182,20 @@ in { | |||
fi | |||
''; | |||
|
|||
environment = mkIf useVersion2 { | |||
# we are actually specifying 4 configuration files: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation is off
pkgs/servers/http/couchdb/2.0.0.nix
Outdated
|
||
''; | ||
|
||
# HACK: this should probably not be hardcoded... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
pkgs/servers/http/couchdb/2.0.0.nix
Outdated
|
||
buildInputs = [ erlang icu openssl spidermonkey ]; | ||
|
||
phases = ["unpackPhase" "patchPhase" "configurePhase" "buildPhase" "installPhase"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to specify the phases. Why isn't fixupPhase
being run?
Some minor remarks but looks good otherwise |
pkgs/servers/http/couchdb/2.0.0.nix
Outdated
> {"-DHAVE_CURL -I/usr/local/include ''$NIX_CFLAGS_COMPILE", "-DHAVE_CURL -lmozjs185 -lcurl"}; | ||
EOF | ||
|
||
patch bin/rebar <<EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you use substituteInPlace
for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I use that to only patch that exact line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
used substituteInPlace for the CFLAGs in the rebar script
@@ -130,7 +139,7 @@ in { | |||
|
|||
configFile = mkOption { | |||
type = types.string; | |||
default = "/var/lib/couchdb/couchdb.ini"; | |||
default = if useVersion2 then "/var/lib/couchdb/local.ini" else "/var/lib/couchdb/couchdb.ini"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's preferred to use mkDefault
in the config section for dynamic defaults like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to use that, but in this case the default depends on another config option. Is that possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahhh nevermind, wrong option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean something like this
config = {
services.couchdb.configFile = mkDefault
(if useVersion2 then "/var/lib/couchdb/local.ini" else "/var/lib/couchdb/couchdb.ini");
};
pkgs/top-level/all-packages.nix
Outdated
couchdb2 = callPackage ../servers/http/couchdb/2.0.0.nix { | ||
spidermonkey = spidermonkey_185; | ||
python = python27; | ||
erlang = erlangR16; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems rather old, it only works with R16
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation mentions Erlang OTP (>=R61B03, =<19.x)
@globin should I squash all the commits into one and force-push them to this PR? |
Yes, please do that. |
Version 2.0.0 is installed as a separate package called "couchdb2". When setting the config option "package" attribute to pkgs.couchdb2, a corresponding service configuration will be generated. If a previous 1.6 installation exists, the databases can still be found on the local port (default: 5986) and can be replicated from there. Note that single-node or cluster setup still needs to be configured manually, as described in http://docs.couchdb.org/en/2.0.0/install/index.html.
I think I addressed everything. |
@globin, @LnL7, @offlinehacker: Is there anything left for me to change on this before it can be merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a test for couchdb, if so could you add one for couchdb2
?
postPatch = '' | ||
substituteInPlace src/couch/rebar.config.script --replace '-DHAVE_CURL -I/usr/local/include' "-DHAVE_CURL -I/usr/local/include $NIX_CFLAGS_COMPILE" | ||
|
||
patch bin/rebar <<EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this also works
substituteInPlace bin/rebase \
--replace '#!/usr/bin/env' '#!${coreutils}/bin/env'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not work. "bin/rebar" is basically a bytecode archive file with a shebang in front to call the interpreter. For some reason that I could not debug, using substituteInPlace does not work in the same way as using patch, and causes the resulting file to be not executable correctly. For that reason, I kept it that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I'm pretty sure I asked that before 😄 .
@LnL7 Sadly, I am not familiar with tests. I did not see one for couchdb in nixos/tests, and there is no checkPhase in the original package either. |
Motivation for this change
Support 2.0.0 CouchDB release
Version 2.0.0 is installed as a separate package called "couchdb2".
When setting the config option "package" attribute to pkgs.couchdb2, a
corresponding service configuration will be generated. If a previous
1.6 installation exists, the databases can still be found on the local
port (default: 5986) and can be replicated from there.
Note that single-node or cluster setup still needs to be configured
manually, as described in
http://docs.couchdb.org/en/2.0.0/install/index.html.
Things done
(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)