1{
2 stdenv,
3 lib,
4 fetchurl,
5 pkg-config,
6 flex,
7 bison,
8 libxslt,
9 autoconf,
10 autoreconfHook,
11 gnome,
12 graphviz,
13 glib,
14 libiconv,
15 libintl,
16 libtool,
17 expat,
18 replaceVars,
19 vala,
20 gobject-introspection,
21}:
22
23let
24 generic = lib.makeOverridable (
25 {
26 version,
27 hash,
28 extraNativeBuildInputs ? [ ],
29 extraBuildInputs ? [ ],
30 withGraphviz ? false,
31 }:
32 let
33 # Build vala (valadoc) without graphviz support. Inspired from the openembedded-core project.
34 # https://github.com/openembedded/openembedded-core/blob/a5440d4288e09d3e/meta/recipes-devtools/vala/vala/disable-graphviz.patch
35 graphvizPatch =
36 {
37 "0.56" = ./disable-graphviz-0.56.8.patch;
38 }
39 .${lib.versions.majorMinor version} or (throw "no graphviz patch for this version of vala");
40
41 disableGraphviz = !withGraphviz;
42
43 in
44 stdenv.mkDerivation rec {
45 pname = "vala";
46 inherit version;
47
48 setupHook = replaceVars ./setup-hook.sh {
49 apiVersion = lib.versions.majorMinor version;
50 };
51
52 src = fetchurl {
53 url = "mirror://gnome/sources/vala/${lib.versions.majorMinor version}/vala-${version}.tar.xz";
54 inherit hash;
55 };
56
57 postPatch = ''
58 patchShebangs tests
59 '';
60
61 # If we're disabling graphviz, apply the patches and corresponding
62 # configure flag. We also need to override the path to the valac compiler
63 # so that it can be used to regenerate documentation.
64 patches = lib.optionals disableGraphviz [ graphvizPatch ];
65 configureFlags = lib.optional disableGraphviz "--disable-graphviz";
66 # when cross-compiling ./compiler/valac is valac for host
67 # so add the build vala in nativeBuildInputs
68 preBuild = lib.optionalString (
69 disableGraphviz && (stdenv.buildPlatform == stdenv.hostPlatform)
70 ) "buildFlagsArray+=(\"VALAC=$(pwd)/compiler/valac\")";
71
72 outputs = [
73 "out"
74 "devdoc"
75 ];
76
77 nativeBuildInputs = [
78 pkg-config
79 flex
80 bison
81 libxslt
82 gobject-introspection
83 ]
84 ++ lib.optional (stdenv.hostPlatform.isDarwin) expat
85 ++ lib.optional disableGraphviz autoreconfHook # if we changed our ./configure script, need to reconfigure
86 ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ vala ]
87 ++ extraNativeBuildInputs;
88
89 buildInputs = [
90 glib
91 libiconv
92 libintl
93 ]
94 ++ lib.optional (withGraphviz) graphviz
95 ++ extraBuildInputs;
96
97 enableParallelBuilding = true;
98
99 doCheck = false; # fails, requires dbus daemon
100
101 passthru = {
102 updateScript = gnome.updateScript {
103 attrPath =
104 let
105 roundUpToEven = num: num + lib.mod num 2;
106 in
107 "vala_${lib.versions.major version}_${builtins.toString (roundUpToEven (lib.toInt (lib.versions.minor version)))}";
108 packageName = "vala";
109 freeze = true;
110 };
111 };
112
113 meta = with lib; {
114 description = "Compiler for GObject type system";
115 homepage = "https://vala.dev";
116 license = licenses.lgpl21Plus;
117 platforms = platforms.unix;
118 maintainers = with maintainers; [
119 antono
120 jtojnar
121 ];
122 teams = [ teams.pantheon ];
123 };
124 }
125 );
126
127in
128rec {
129 vala_0_56 = generic {
130 version = "0.56.18";
131 hash = "sha256-8q/+fUCrY9uOe57MP2vcnC/H4xNMhP8teV9IL+kmo4I=";
132 };
133
134 vala = vala_0_56;
135}