python3Packages.instructor: 1.6.4 -> 1.72 (#378975)
[NixPkgs.git] / pkgs / development / ada-modules / gnatcoll / db.nix
blob1a670b5abf60e35d3d6504f6ab6d7edee31a73e5
1 { stdenv
2 , lib
3 , fetchFromGitHub
4 , gnat
5 , gprbuild
6 , which
7 , gnatcoll-core
8 , component
9 # components built by this derivation other components depend on
10 , gnatcoll-sql
11 , gnatcoll-sqlite
12 , gnatcoll-xref
13 # component specific extra dependencies
14 , gnatcoll-iconv
15 , gnatcoll-readline
16 , sqlite
17 , postgresql
20 let
21   libsFor = {
22     gnatcoll_db2ada = [
23       gnatcoll-sql
24     ];
25     gnatinspect = [
26       gnatcoll-sqlite
27       gnatcoll-readline
28       gnatcoll-xref
29     ];
30     postgres = [
31       gnatcoll-sql
32       postgresql
33     ];
34     sqlite = [
35       gnatcoll-sql
36       sqlite
37     ];
38     xref = [
39       gnatcoll-iconv
40       gnatcoll-sqlite
41     ];
42   };
44   # These components are just tools and don't install a library
45   onlyExecutable = builtins.elem component [
46     "gnatcoll_db2ada"
47     "gnatinspect"
48   ];
51 stdenv.mkDerivation rec {
52   # executables don't adhere to the string gnatcoll-* scheme
53   pname =
54     if onlyExecutable
55     then builtins.replaceStrings [ "_" ] [ "-" ] component
56     else "gnatcoll-${component}";
57   version = "25.0.0";
59   src = fetchFromGitHub {
60     owner = "AdaCore";
61     repo = "gnatcoll-db";
62     rev = "v${version}";
63     sha256 = "0q35ii0aa4hh59v768l5cilg1b30a4ckcvlbfy0lkcbp3rcfnbz3";
64   };
66   # Link executables dynamically unless specified by the platform,
67   # as we usually do in nixpkgs where possible
68   postPatch = lib.optionalString (!stdenv.hostPlatform.isStatic) ''
69     for f in gnatcoll_db2ada/Makefile gnatinspect/Makefile; do
70       substituteInPlace "$f" --replace "=static" "=relocatable"
71     done
72   '';
74   nativeBuildInputs = [
75     gnat
76     gprbuild
77     which
78   ];
80   # Propagate since GPRbuild needs to find referenced .gpr files
81   # and other libraries to link against when static linking is used.
82   # For executables this is of course not relevant and we can reduce
83   # the closure size dramatically
84   ${if onlyExecutable then "buildInputs" else "propagatedBuildInputs"} = [
85     gnatcoll-core
86   ] ++ libsFor."${component}" or [];
88   makeFlags = [
89     "-C" component
90     "PROCESSORS=$(NIX_BUILD_CORES)"
91     # confusingly, for gprbuild --target is autoconf --host
92     "TARGET=${stdenv.hostPlatform.config}"
93     "prefix=${placeholder "out"}"
94   ] ++ lib.optionals (component == "sqlite") [
95     # link against packaged, not vendored libsqlite3
96     "GNATCOLL_SQLITE=external"
97   ];
99   meta = with lib; {
100     description = "GNAT Components Collection - Database packages";
101     homepage = "https://github.com/AdaCore/gnatcoll-db";
102     license = licenses.gpl3Plus;
103     maintainers = [ maintainers.sternenseemann ];
104     platforms = platforms.all;
105   };