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