Merge sublime4: 4189 -> 4192; sublime4-dev: 4188 -> 4191 (#378651)
[NixPkgs.git] / pkgs / development / compilers / vala / default.nix
blob0285a53554611428a284b05b2af7c56f8bfb2d32
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   substituteAll,
19   vala,
20   gobject-introspection,
23 let
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");
41       disableGraphviz = !withGraphviz;
43     in
44     stdenv.mkDerivation rec {
45       pname = "vala";
46       inherit version;
48       setupHook = substituteAll {
49         src = ./setup-hook.sh;
50         apiVersion = lib.versions.majorMinor version;
51       };
53       src = fetchurl {
54         url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
55         inherit hash;
56       };
58       postPatch = ''
59         patchShebangs tests
60       '';
62       # If we're disabling graphviz, apply the patches and corresponding
63       # configure flag. We also need to override the path to the valac compiler
64       # so that it can be used to regenerate documentation.
65       patches = lib.optionals disableGraphviz [ graphvizPatch ];
66       configureFlags = lib.optional disableGraphviz "--disable-graphviz";
67       # when cross-compiling ./compiler/valac is valac for host
68       # so add the build vala in nativeBuildInputs
69       preBuild = lib.optionalString (
70         disableGraphviz && (stdenv.buildPlatform == stdenv.hostPlatform)
71       ) "buildFlagsArray+=(\"VALAC=$(pwd)/compiler/valac\")";
73       outputs = [
74         "out"
75         "devdoc"
76       ];
78       nativeBuildInputs =
79         [
80           pkg-config
81           flex
82           bison
83           libxslt
84           gobject-introspection
85         ]
86         ++ lib.optional (stdenv.hostPlatform.isDarwin) expat
87         ++ lib.optional disableGraphviz autoreconfHook # if we changed our ./configure script, need to reconfigure
88         ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ vala ]
89         ++ extraNativeBuildInputs;
91       buildInputs =
92         [
93           glib
94           libiconv
95           libintl
96         ]
97         ++ lib.optional (withGraphviz) graphviz
98         ++ extraBuildInputs;
100       enableParallelBuilding = true;
102       doCheck = false; # fails, requires dbus daemon
104       passthru = {
105         updateScript = gnome.updateScript {
106           attrPath =
107             let
108               roundUpToEven = num: num + lib.mod num 2;
109             in
110             "${pname}_${lib.versions.major version}_${builtins.toString (roundUpToEven (lib.toInt (lib.versions.minor version)))}";
111           packageName = pname;
112           freeze = true;
113         };
114       };
116       meta = with lib; {
117         description = "Compiler for GObject type system";
118         homepage = "https://vala.dev";
119         license = licenses.lgpl21Plus;
120         platforms = platforms.unix;
121         maintainers =
122           with maintainers;
123           [
124             antono
125             jtojnar
126           ]
127           ++ teams.pantheon.members;
128       };
129     }
130   );
133 rec {
134   vala_0_56 = generic {
135     version = "0.56.17";
136     hash = "sha256-JhAMTk7wBJxhknXxQNl89WWIPQDHVDyCvM5aQmk07Wo=";
137   };
139   vala = vala_0_56;