Skip to content
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

Merged
merged 1 commit into from Mar 16, 2017
Merged

Conversation

timor
Copy link
Member

@timor timor commented Feb 17, 2017

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
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@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.

@timor
Copy link
Member Author

timor commented Feb 17, 2017

@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;
Copy link
Member

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)

Copy link
Member Author

@timor timor Feb 20, 2017

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 ];
Copy link
Member

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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation is off


'';

# HACK: this should probably not be hardcoded...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?


buildInputs = [ erlang icu openssl spidermonkey ];

phases = ["unpackPhase" "patchPhase" "configurePhase" "buildPhase" "installPhase"];
Copy link
Member

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?

@globin
Copy link
Member

globin commented Feb 17, 2017

Some minor remarks but looks good otherwise

> {"-DHAVE_CURL -I/usr/local/include ''$NIX_CFLAGS_COMPILE", "-DHAVE_CURL -lmozjs185 -lcurl"};
EOF

patch bin/rebar <<EOF
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member Author

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";
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhh nevermind, wrong option.

Copy link
Member

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");
  };

couchdb2 = callPackage ../servers/http/couchdb/2.0.0.nix {
spidermonkey = spidermonkey_185;
python = python27;
erlang = erlangR16;
Copy link
Member

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?

Copy link
Member

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)

@timor
Copy link
Member Author

timor commented Feb 23, 2017

@globin should I squash all the commits into one and force-push them to this PR?

@offlinehacker
Copy link
Contributor

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.
@timor
Copy link
Member Author

timor commented Mar 6, 2017

I think I addressed everything.

@timor
Copy link
Member Author

timor commented Mar 14, 2017

@globin, @LnL7, @offlinehacker:

Is there anything left for me to change on this before it can be merged?

Copy link
Member

@LnL7 LnL7 left a 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
Copy link
Member

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'

Copy link
Member Author

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.

Copy link
Member

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 😄 .

@timor
Copy link
Member Author

timor commented Mar 15, 2017

@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.

@LnL7 LnL7 merged commit 00ed0f7 into NixOS:master Mar 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants