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 3.0.0 #84246

Merged
merged 1 commit into from Sep 11, 2020
Merged

Conversation

lostnet
Copy link
Contributor

@lostnet lostnet commented Apr 4, 2020

Motivation for this change

couchdb 3 has been released as a major cleanup release.

Things done
  • Add couchdb3 package as a choice for the service
  • Use its spidermonkey 60 support to not depend on older versions
  • Add adminUser/adminPass options since 3.0 finally fully disabled admin-party mode
  • Refactor tests a little for 3 versions and the lack of admin-party mode

tasks:

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
    (None were reported by the wip review)
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
    (I think the only relevant documentation is autogenerated from option descriptions, etc?)
  • Fits CONTRIBUTING.md.

@DamienCassou
Copy link
Contributor

What is the status of this PR? Can you please update it to latest master to avoid the conflict?

@lostnet
Copy link
Contributor Author

lostnet commented Aug 28, 2020

@DamienCassou The last maintainer for couchdb2 seemed to have removed themself, so I wasn't sure if there's someone with enough interest in couchdb and experience in nixos to review this. I've updated this request against master.

It would now also make sense to update the couchdb3 version to 3.1.0 with spidermonkey_68. I have some changes for that which I can either integrate into this pull request or a subsequent pull request.

Thanks!

@DamienCassou
Copy link
Contributor

DamienCassou commented Aug 29, 2020 via email

@lostnet
Copy link
Contributor Author

lostnet commented Sep 8, 2020

Hi @DamienCassou I've updated the commit to the latest couchdb version and checked that it must be using the newer version of spidermonkey correctly by using ES6(fat-arrow) and ES10(Object.fromEntries) in a design document. It seems functionally good to me, please let me know if there's anything I can improve to make it suitable for merging.
Thanks,
Will Young

@DamienCassou
Copy link
Contributor

Result of nixpkgs-review pr 84246 1

1 package blacklisted:
  • tests.nixos-functions.nixos-test
1 package built:
  • couchdb3

Copy link
Contributor

@DamienCassou DamienCassou left a comment

Choose a reason for hiding this comment

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

I think this is really great work. Thank you. I'm no expert so please take my feedback with a grain of salt. Feel free to ask others for feedback on IRC or on discourse.

@@ -16185,6 +16185,10 @@ in
erlang = erlangR21;
};

couchdb3 = callPackage ../servers/http/couchdb/3.0.0.nix {
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't the filename be 3.nix instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here I'd followed the 2.0.0.nix and used it as a template (relevant bellow). I kind of thought the semver made sense, but probably more for versions like 1.X and 4.X than 2 and 3, since couchdb2&couchdb3 don't have so much going on that is likely to accidentally break compatibility between their minor versions. I could rename both files 2.nix and 3.nix?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know

version = "3.1.0";


# when updating this, please consider bumping the OTP version
Copy link
Contributor

Choose a reason for hiding this comment

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

what do you mean by OTP?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is from the 2.0.0.nix and is referring to the erlang/otp version. I removed it entirely since the current version for erlang in nixos is 22 and couchdb3 accepts 22.X, but I will hardcode it to erlang = erlangR22 since couchdb3's pinning is unlikely to keep up with nix's default erlang.

postPatch = ''
substituteInPlace src/couch/rebar.config.script --replace '/usr/include/mozjs-68' "${spidermonkey.dev}/include/mozjs-68"

patch bin/rebar <<EOF
Copy link
Contributor

Choose a reason for hiding this comment

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

why isn't that automatically patched by patchShebang?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rebar2 is used at configure/build so fixup is too late, but I changed this to manually call patchShebang.

postPatch = ''
substituteInPlace src/couch/rebar.config.script --replace '/usr/include/mozjs-68' "${spidermonkey.dev}/include/mozjs-68"

patch bin/rebar <<EOF
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess substituteInPlace would be cleaner than patch here.


patch bin/rebar <<EOF
1c1
< #!/usr/bin/env escript
Copy link
Contributor

Choose a reason for hiding this comment

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

I think nixpkgs usually use patches in context or unified formats (i.e., + and - instead of < and >). I might be wrong though.

1c1
< #!/usr/bin/env escript
---
> #!${coreutils}/bin/env escript
Copy link
Contributor

Choose a reason for hiding this comment

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

why going through env instead of directly #!${pkgs.erlang}/bin/escript?

'';

configurePhase = ''
./configure --spidermonkey-version 68
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should use configureFlagsArray instead

'';

buildPhase = ''
make release
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should use makeFlagsArray or buildFlagsArray.

installPhase = ''
mkdir -p $out
cp -r rel/couchdb/* $out
wrapProgram $out/bin/couchdb --suffix PATH : ${bash}/bin
Copy link
Contributor

Choose a reason for hiding this comment

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

why is the wrapping necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only purpose seemed to be to achieve the same as patchShebang for the original couchdb script, since patchShebang is fixing the original script, I've removed the wrapping.


meta = with stdenv.lib; {
description = "A database that uses JSON for documents, JavaScript for MapReduce queries, and regular HTTP for an API";
homepage = http://couchdb.apache.org;
Copy link
Contributor

Choose a reason for hiding this comment

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

unquoted urls are deprecated by NixOS/rfcs#45. Please use double-quotes.

@DamienCassou
Copy link
Contributor

Result of nixpkgs-review pr 84246 1

1 package blacklisted:
  • tests.nixos-functions.nixos-test
1 package built:
  • couchdb3

@DamienCassou DamienCassou merged commit 607f5a6 into NixOS:master Sep 11, 2020
@DamienCassou
Copy link
Contributor

Really good job, thank you!

@lostnet
Copy link
Contributor Author

lostnet commented Sep 11, 2020

Thank you @DamienCassou, I'm very happy with how well the couchdb3 definition cleaned up with your review!

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

3 participants