3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/libraries/inchi/default.nix

75 lines
2.1 KiB
Nix
Raw Normal View History

2021-03-19 20:13:41 +00:00
{ fetchurl
2020-12-23 02:55:05 +00:00
, lib
, stdenv
, unzip
, fixDarwinDylibNames
}:
2021-03-19 20:13:41 +00:00
let
versionMajor = "1";
versionMinor = "0.6";
version = versionMajor + "." + versionMinor;
removeDots = lib.replaceStrings [ "." ] [ "" ];
src-doc = fetchurl {
url = "http://www.inchi-trust.org/download/${removeDots version}/INCHI-1-DOC.zip";
sha256 = "1kyda09i9p89xfq90ninwi7w13k1w3ljpl4gqdhpfhi5g8fgxx7f";
};
in
stdenv.mkDerivation rec {
pname = "inchi";
inherit version;
2020-11-22 22:02:20 +00:00
2021-03-19 20:13:41 +00:00
src = fetchurl {
url = "http://www.inchi-trust.org/download/${removeDots version}/INCHI-1-SRC.zip";
sha256 = "1zbygqn0443p0gxwr4kx3m1bkqaj8x9hrpch3s41py7jq08f6x28";
};
2020-11-22 22:02:20 +00:00
2021-03-19 20:13:41 +00:00
nativeBuildInputs = [ unzip ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
outputs = [ "out" "doc" ];
2020-11-22 22:02:20 +00:00
2021-03-19 20:13:41 +00:00
enableParallelBuilding = true;
2020-12-23 02:55:05 +00:00
2021-03-19 20:13:41 +00:00
preConfigure = ''
cd ./INCHI_API/libinchi/gcc
'' + lib.optionalString stdenv.isDarwin ''
substituteInPlace makefile \
--replace ",--version-script=libinchi.map" "" \
--replace "LINUX_Z_RELRO = ,-z,relro" "" \
--replace "-soname" "-install_name" \
--replace "gcc" $CC
'';
installPhase = let
versionOneDot = versionMajor + "." + removeDots versionMinor;
in ''
runHook preInstall
cd ../../..
mkdir -p $out/lib
mkdir -p $out/include/inchi
mkdir -p $doc/share/
2020-11-22 22:02:20 +00:00
2021-03-19 20:13:41 +00:00
install -m 755 INCHI_API/bin/Linux/libinchi.so.${versionOneDot}.00 $out/lib
ln -s $out/lib/libinchi.so.${versionOneDot}.00 $out/lib/libinchi.so.1
ln -s $out/lib/libinchi.so.${versionOneDot}.00 $out/lib/libinchi.so
install -m 644 INCHI_BASE/src/*.h $out/include/inchi
2020-11-22 22:02:20 +00:00
2021-03-19 20:13:41 +00:00
runHook postInstall
'';
2020-11-22 22:02:20 +00:00
2021-03-19 20:13:41 +00:00
preFixup = lib.optionalString stdenv.isDarwin ''
fixDarwinDylibNames $(find "$out" -name "*.so.*")
'';
2020-12-23 02:55:05 +00:00
2021-03-19 20:13:41 +00:00
postInstall = ''
2020-11-22 22:02:20 +00:00
unzip '${src-doc}'
install -m 644 INCHI-1-DOC/*.pdf $doc/share
'';
2021-03-19 20:13:41 +00:00
meta = with lib; {
homepage = "https://www.inchi-trust.org/";
description = "IUPAC International Chemical Identifier library";
license = licenses.lgpl2Plus;
maintainers = with maintainers; [ rmcgibbo ];
};
}