1{ stdenv
2, lib
3, fetchFromGitHub
4, gnat
5, which
6, xmlada # for src
7}:
8
9let
10 version = "23.0.0";
11
12 gprConfigKbSrc = fetchFromGitHub {
13 name = "gprconfig-kb-${version}-src";
14 owner = "AdaCore";
15 repo = "gprconfig_kb";
16 rev = "v${version}";
17 sha256 = "1rhskq4r2plf3ia67k08misygnpr9knzw3kp3kyv5778lra8y6s2";
18 };
19in
20
21stdenv.mkDerivation {
22 pname = "gprbuild-boot";
23 inherit version;
24
25 src = fetchFromGitHub {
26 name = "gprbuild-${version}";
27 owner = "AdaCore";
28 repo = "gprbuild";
29 rev = "v${version}";
30 sha256 = "1ciaq4nh98vd7r5i11v353c1ms9s5yph0yxk4fkryc6bvkm4666x";
31 };
32
33 nativeBuildInputs = [
34 gnat
35 which
36 ];
37
38 postPatch = ''
39 # The Makefile uses gprbuild to build gprbuild which
40 # we can't do at this point, delete it to prevent the
41 # default phases from failing.
42 rm Makefile
43
44 # make sure bootstrap script runs
45 patchShebangs --build bootstrap.sh
46 '';
47
48 # This setupHook populates GPR_PROJECT_PATH which is used by
49 # gprbuild to find dependencies. It works quite similar to
50 # the pkg-config setupHook in the sense that it also splits
51 # dependencies into GPR_PROJECT_PATH and GPR_PROJECT_PATH_FOR_BUILD,
52 # but gprbuild itself doesn't support this, so we'll need to
53 # introducing a wrapper for it in the future remains TODO.
54 # For the moment this doesn't matter since we have no situation
55 # were gprbuild is used to build something used at build time.
56 setupHooks = [
57 ./gpr-project-path-hook.sh
58 ] ++ lib.optionals stdenv.targetPlatform.isDarwin [
59 # This setupHook replaces the paths of shared libraries starting
60 # with @rpath with the absolute paths on Darwin, so that the
61 # binaries can be run without additional setup.
62 ./gpr-project-darwin-rpath-hook.sh
63 ];
64
65 installPhase = ''
66 runHook preInstall
67
68 ./bootstrap.sh \
69 --with-xmlada=${xmlada.src} \
70 --with-kb=${gprConfigKbSrc} \
71 --prefix=$out
72
73 # Install custom compiler description which can detect nixpkgs'
74 # GNAT wrapper as a proper Ada compiler. The default compiler
75 # description expects the runtime library to be installed in
76 # the same prefix which isn't the case for nixpkgs. As a
77 # result, it would detect the unwrapped GNAT as a proper
78 # compiler which is unable to produce working binaries.
79 #
80 # Our compiler description is very similar to the upstream
81 # GNAT description except that we use a symlink in $out/nix-support
82 # created by the cc-wrapper to find the associated runtime
83 # libraries and use gnatmake instead of gnatls to find GNAT's
84 # bin directory.
85 install -m644 ${./nixpkgs-gnat.xml} $out/share/gprconfig/nixpkgs-gnat.xml
86
87 runHook postInstall
88 '';
89
90 meta = with lib; {
91 description = "Multi-language extensible build tool";
92 homepage = "https://github.com/AdaCore/gprbuild";
93 license = licenses.gpl3Plus;
94 maintainers = [ maintainers.sternenseemann ];
95 platforms = platforms.all;
96 };
97}