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