zoxide: 0.9.6 -> 0.9.7 (#380745)
[NixPkgs.git] / pkgs / by-name / gj / gjs / package.nix
blob55342995339ddd7aba21820b683acbe6a49b20f7
2   fetchurl,
3   lib,
4   stdenv,
5   meson,
6   mesonEmulatorHook,
7   ninja,
8   pkg-config,
9   gnome,
10   gtk3,
11   atk,
12   gobject-introspection,
13   spidermonkey_128,
14   pango,
15   cairo,
16   readline,
17   libsysprof-capture,
18   glib,
19   libxml2,
20   dbus,
21   gdk-pixbuf,
22   harfbuzz,
23   makeWrapper,
24   which,
25   xvfb-run,
26   nixosTests,
27   installTests ? true,
30 let
31   testDeps = [
32     gtk3
33     atk
34     pango.out
35     gdk-pixbuf
36     harfbuzz
37     glib.out
38   ];
40 stdenv.mkDerivation (finalAttrs: {
41   pname = "gjs";
42   version = "1.82.1";
44   outputs = [
45     "out"
46     "dev"
47     "installedTests"
48   ];
50   src = fetchurl {
51     url = "mirror://gnome/sources/gjs/${lib.versions.majorMinor finalAttrs.version}/gjs-${finalAttrs.version}.tar.xz";
52     hash = "sha256-+zmqVjZXbeDloRcfVqGlgl4r0aaZcvsSC6eL0Qm1aTw=";
53   };
55   patches = [
56     # Hard-code various paths
57     ./fix-paths.patch
59     # Allow installing installed tests to a separate output.
60     ./installed-tests-path.patch
62     # Disable introspection test in installed tests
63     # (minijasmine:1317): GLib-GIO-WARNING **: 17:33:39.556: Error creating IO channel for /proc/self/mountinfo: No such file or directory (g-io-error-quark, 1)
64     ./disable-introspection-test.patch
65   ];
67   nativeBuildInputs =
68     [
69       meson
70       ninja
71       pkg-config
72       makeWrapper
73       which # for locale detection
74       libxml2 # for xml-stripblanks
75       dbus # for dbus-run-session
76       gobject-introspection
77     ]
78     ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
79       mesonEmulatorHook
80     ];
82   buildInputs = [
83     cairo
84     readline
85     libsysprof-capture
86     spidermonkey_128
87   ];
89   nativeCheckInputs = [
90     xvfb-run
91   ] ++ testDeps;
93   propagatedBuildInputs = [
94     glib
95   ];
97   mesonFlags =
98     [
99       "-Dinstalled_test_prefix=${placeholder "installedTests"}"
100     ]
101     ++ lib.optionals (!stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isMusl) [
102       "-Dprofiler=disabled"
103     ];
105   doCheck = !stdenv.hostPlatform.isDarwin;
107   postPatch =
108     ''
109       patchShebangs build/choose-tests-locale.sh
110       substituteInPlace installed-tests/debugger-test.sh --subst-var-by gjsConsole $out/bin/gjs-console
111     ''
112     + lib.optionalString stdenv.hostPlatform.isMusl ''
113       substituteInPlace installed-tests/js/meson.build \
114         --replace "'Encoding'," "#'Encoding',"
115     '';
117   preCheck = ''
118     # Our gobject-introspection patches make the shared library paths absolute
119     # in the GIR files. When running tests, the library is not yet installed,
120     # though, so we need to replace the absolute path with a local one during build.
121     # We are using a symlink that will be overridden during installation.
122     mkdir -p $out/lib $installedTests/libexec/installed-tests/gjs
123     ln -s $PWD/libgjs.so.0 $out/lib/libgjs.so.0
124     ln -s $PWD/subprojects/gobject-introspection-tests/libgimarshallingtests.so $installedTests/libexec/installed-tests/gjs/libgimarshallingtests.so
125     ln -s $PWD/subprojects/gobject-introspection-tests/libregress.so $installedTests/libexec/installed-tests/gjs/libregress.so
126     ln -s $PWD/subprojects/gobject-introspection-tests/libwarnlib.so $installedTests/libexec/installed-tests/gjs/libwarnlib.so
127     ln -s $PWD/installed-tests/js/libgjstesttools/libgjstesttools.so $installedTests/libexec/installed-tests/gjs/libgjstesttools.so
128   '';
130   postInstall = ''
131     # TODO: make the glib setup hook handle moving the schemas in other outputs.
132     installedTestsSchemaDatadir="$installedTests/share/gsettings-schemas/gjs-${finalAttrs.version}"
133     mkdir -p "$installedTestsSchemaDatadir"
134     mv "$installedTests/share/glib-2.0" "$installedTestsSchemaDatadir"
135   '';
137   postFixup = lib.optionalString installTests ''
138     wrapProgram "$installedTests/libexec/installed-tests/gjs/minijasmine" \
139       --prefix XDG_DATA_DIRS : "$installedTestsSchemaDatadir" \
140       --prefix GI_TYPELIB_PATH : "${lib.makeSearchPath "lib/girepository-1.0" testDeps}"
141   '';
143   checkPhase = ''
144     runHook preCheck
145     xvfb-run -s '-screen 0 800x600x24' \
146       meson test --print-errorlogs
147     runHook postCheck
148   '';
150   separateDebugInfo = stdenv.hostPlatform.isLinux;
152   passthru = {
153     tests = {
154       installed-tests = nixosTests.installed-tests.gjs;
155     };
157     updateScript = gnome.updateScript {
158       packageName = "gjs";
159       versionPolicy = "odd-unstable";
160     };
161   };
163   meta = with lib; {
164     description = "JavaScript bindings for GNOME";
165     homepage = "https://gitlab.gnome.org/GNOME/gjs/blob/master/doc/Home.md";
166     license = licenses.lgpl2Plus;
167     mainProgram = "gjs";
168     maintainers = teams.gnome.members;
169     platforms = platforms.unix;
170   };