nixpkgs/pkgs/servers/http/couchdb/3.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

71 lines
1.7 KiB
Nix

{ lib
, stdenv
, fetchurl
, erlang
, icu
, openssl
, spidermonkey_91
, python3
, nixosTests
}:
stdenv.mkDerivation rec {
pname = "couchdb";
version = "3.3.3";
src = fetchurl {
url = "mirror://apache/couchdb/source/${version}/apache-${pname}-${version}.tar.gz";
hash = "sha256-eiAHtfZz1L4iolyaER2QZpGdhy3bkTWn3OwBIimb054=";
};
postPatch = ''
substituteInPlace src/couch/rebar.config.script --replace '/usr/include/mozjs-91' "${spidermonkey_91.dev}/include/mozjs-91"
substituteInPlace configure --replace '/usr/include/''${SM_HEADERS}' "${spidermonkey_91.dev}/include/mozjs-91"
patchShebangs bin/rebar
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
# LTO with Clang produces LLVM bitcode, which causes linking to fail quietly.
# (There are warnings, but no hard errors, and it produces an empty dylib.)
substituteInPlace src/jiffy/rebar.config.script --replace '"-flto"' '""'
'';
nativeBuildInputs = [
erlang
];
buildInputs = [
icu
openssl
spidermonkey_91
(python3.withPackages(ps: with ps; [ requests ]))
];
dontAddPrefix= "True";
configureFlags = [
"--spidermonkey-version=91"
];
buildFlags = [
"release"
];
installPhase = ''
runHook preInstall
mkdir -p $out
cp -r rel/couchdb/* $out
runHook postInstall
'';
passthru.tests = {
inherit (nixosTests) couchdb;
};
meta = with lib; {
description = "Database that uses JSON for documents, JavaScript for MapReduce queries, and regular HTTP for an API";
homepage = "https://couchdb.apache.org";
license = licenses.asl20;
platforms = platforms.all;
maintainers = with maintainers; [ lostnet ];
};
}