diff options
author | Thomas Heijligen <src@posteo.de> | 2024-02-19 20:17:42 +0000 |
---|---|---|
committer | sternenseemann <sternenseemann@systemli.org> | 2024-02-25 18:19:50 +0100 |
commit | f2a142727cc0fbc92a9b420567418df9dd36e568 (patch) | |
tree | b682a81e81f481982046e52f820210c5549933a0 /pkgs/development/ada-modules/gnatcoll | |
parent | c02503b58237072965308415f87e709af128516c (diff) |
gnatPackages: Add scope for all ada packages
Ada depencencies musst be build with the same gnat version as the project. Use a namespace as preperation to build with different gnat versions. gprbuild and gnatprove are still globaly visable.
Diffstat (limited to 'pkgs/development/ada-modules/gnatcoll')
-rw-r--r-- | pkgs/development/ada-modules/gnatcoll/bindings.nix | 89 | ||||
-rw-r--r-- | pkgs/development/ada-modules/gnatcoll/core.nix | 47 | ||||
-rw-r--r-- | pkgs/development/ada-modules/gnatcoll/db.nix | 107 |
3 files changed, 243 insertions, 0 deletions
diff --git a/pkgs/development/ada-modules/gnatcoll/bindings.nix b/pkgs/development/ada-modules/gnatcoll/bindings.nix new file mode 100644 index 0000000000000..c8896c14c32f9 --- /dev/null +++ b/pkgs/development/ada-modules/gnatcoll/bindings.nix @@ -0,0 +1,89 @@ +{ stdenv +, lib +, fetchFromGitHub +, gnat +, gprbuild +, gnatcoll-core +, component +# component dependencies +, gmp +, libiconv +, xz +, gcc-unwrapped +, readline +, zlib +, python3 +, ncurses +, darwin +}: + +let + # omit python (2.7), no need to introduce a + # dependency on an EOL package for no reason + libsFor = { + iconv = [ libiconv ]; + gmp = [ gmp ]; + lzma = [ xz ]; + readline = [ readline ]; + python3 = [ python3 ncurses ]; + syslog = [ ]; + zlib = [ zlib ]; + }; +in + + +stdenv.mkDerivation rec { + pname = "gnatcoll-${component}"; + version = "24.0.0"; + + src = fetchFromGitHub { + owner = "AdaCore"; + repo = "gnatcoll-bindings"; + rev = "v${version}"; + sha256 = "00aakpmr67r72l1h3jpkaw83p1a2mjjvfk635yy5c1nss3ji1qjm"; + }; + + nativeBuildInputs = [ + gprbuild + gnat + python3 + ]; + + buildInputs = lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.CoreFoundation + ]; + + # propagate since gprbuild needs to find referenced .gpr files + # and all dependency C libraries when statically linking a + # downstream executable. + propagatedBuildInputs = [ + gnatcoll-core + ] ++ libsFor."${component}" or []; + + # explicit flag for GPL acceptance because upstreams + # allows a gcc runtime exception for all bindings + # except for readline (since it is GPL w/o exceptions) + buildFlags = lib.optionals (component == "readline") [ + "--accept-gpl" + ]; + + buildPhase = '' + runHook preBuild + ${python3.interpreter} ${component}/setup.py build --prefix $out $buildFlags + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + ${python3.interpreter} ${component}/setup.py install --prefix $out + runHook postInstall + ''; + + meta = with lib; { + description = "GNAT Components Collection - Bindings to C libraries"; + homepage = "https://github.com/AdaCore/gnatcoll-bindings"; + license = licenses.gpl3Plus; + platforms = platforms.all; + maintainers = [ maintainers.sternenseemann ]; + }; +} diff --git a/pkgs/development/ada-modules/gnatcoll/core.nix b/pkgs/development/ada-modules/gnatcoll/core.nix new file mode 100644 index 0000000000000..7fdd4e99d550b --- /dev/null +++ b/pkgs/development/ada-modules/gnatcoll/core.nix @@ -0,0 +1,47 @@ +{ stdenv +, lib +, gnat +, gprbuild +, fetchFromGitHub +, xmlada +, which +}: + +stdenv.mkDerivation rec { + pname = "gnatcoll-core"; + version = "24.0.0"; + + src = fetchFromGitHub { + owner = "AdaCore"; + repo = "gnatcoll-core"; + rev = "v${version}"; + sha256 = "1cks2w0inj9hvamsdxjriwxnx1igmx2khhr6kwxshsl30rs8nzvb"; + }; + + nativeBuildInputs = [ + gprbuild + which + gnat + ]; + + # propagate since gprbuild needs to find + # referenced GPR project definitions + propagatedBuildInputs = [ + gprbuild # libgpr + ]; + + makeFlags = [ + "prefix=${placeholder "out"}" + "PROCESSORS=$(NIX_BUILD_CORES)" + # confusingly, for gprbuild --target is autoconf --host + "TARGET=${stdenv.hostPlatform.config}" + ]; + + meta = with lib; { + homepage = "https://github.com/AdaCore/gnatcoll-core"; + description = "GNAT Components Collection - Core packages"; + license = licenses.gpl3Plus; + maintainers = [ maintainers.sternenseemann ]; + platforms = platforms.all; + }; +} diff --git a/pkgs/development/ada-modules/gnatcoll/db.nix b/pkgs/development/ada-modules/gnatcoll/db.nix new file mode 100644 index 0000000000000..6eacff1ddb82f --- /dev/null +++ b/pkgs/development/ada-modules/gnatcoll/db.nix @@ -0,0 +1,107 @@ +{ stdenv +, lib +, fetchFromGitHub +, gnat +, gprbuild +, which +, gnatcoll-core +, xmlada +, component +# components built by this derivation other components depend on +, gnatcoll-sql +, gnatcoll-sqlite +, gnatcoll-xref +# component specific extra dependencies +, gnatcoll-iconv +, gnatcoll-readline +, sqlite +, postgresql +}: + +let + libsFor = { + gnatcoll_db2ada = [ + gnatcoll-sql + ]; + gnatinspect = [ + gnatcoll-sqlite + gnatcoll-readline + gnatcoll-xref + ]; + postgres = [ + gnatcoll-sql + postgresql + ]; + sqlite = [ + gnatcoll-sql + sqlite + ]; + xref = [ + gnatcoll-iconv + gnatcoll-sqlite + ]; + }; + + # These components are just tools and don't install a library + onlyExecutable = builtins.elem component [ + "gnatcoll_db2ada" + "gnatinspect" + ]; +in + +stdenv.mkDerivation rec { + # executables don't adhere to the string gnatcoll-* scheme + pname = + if onlyExecutable + then builtins.replaceStrings [ "_" ] [ "-" ] component + else "gnatcoll-${component}"; + version = "24.0.0"; + + src = fetchFromGitHub { + owner = "AdaCore"; + repo = "gnatcoll-db"; + rev = "v${version}"; + sha256 = "0jq76s4s7q2x93jh8la6r0i3jkpvgsfj12vbbaqabh410xccyr3p"; + }; + + # Link executables dynamically unless specified by the platform, + # as we usually do in nixpkgs where possible + postPatch = lib.optionalString (!stdenv.hostPlatform.isStatic) '' + for f in gnatcoll_db2ada/Makefile gnatinspect/Makefile; do + substituteInPlace "$f" --replace "=static" "=relocatable" + done + ''; + + nativeBuildInputs = [ + gnat + gprbuild + which + ]; + + # Propagate since GPRbuild needs to find referenced .gpr files + # and other libraries to link against when static linking is used. + # For executables this is of course not relevant and we can reduce + # the closure size dramatically + ${if onlyExecutable then "buildInputs" else "propagatedBuildInputs"} = [ + gnatcoll-core + ] ++ libsFor."${component}" or []; + + makeFlags = [ + "-C" component + "PROCESSORS=$(NIX_BUILD_CORES)" + # confusingly, for gprbuild --target is autoconf --host + "TARGET=${stdenv.hostPlatform.config}" + "prefix=${placeholder "out"}" + ] ++ lib.optionals (component == "sqlite") [ + # link against packaged, not vendored libsqlite3 + "GNATCOLL_SQLITE=external" + ]; + + meta = with lib; { + description = "GNAT Components Collection - Database packages"; + homepage = "https://github.com/AdaCore/gnatcoll-db"; + license = licenses.gpl3Plus; + maintainers = [ maintainers.sternenseemann ]; + platforms = platforms.all; + }; +} |