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