2020-04-24 23:36:52 +00:00
{ fetchurl
2021-05-20 23:08:51 +00:00
, lib
, stdenv
2020-04-24 23:36:52 +00:00
, meson
2022-09-30 11:47:45 +00:00
, mesonEmulatorHook
2020-04-24 23:36:52 +00:00
, ninja
2021-02-05 17:12:51 +00:00
, pkg-config
2021-05-20 23:08:51 +00:00
, gnome
2020-04-24 23:36:52 +00:00
, gtk3
, atk
, gobject-introspection
2024-01-02 11:29:13 +00:00
, spidermonkey_115
2020-04-24 23:36:52 +00:00
, pango
, cairo
, readline
2022-07-14 12:49:19 +00:00
, libsysprof-capture
2020-04-24 23:36:52 +00:00
, glib
, libxml2
, dbus
, gdk-pixbuf
2021-05-20 23:08:51 +00:00
, harfbuzz
2020-04-24 23:36:52 +00:00
, makeWrapper
2020-06-18 07:06:33 +00:00
, which
2021-05-20 23:08:51 +00:00
, xvfb-run
2020-04-24 23:36:52 +00:00
, nixosTests
2024-01-13 08:15:51 +00:00
, installTests ? true
2020-04-24 23:36:52 +00:00
} :
let
testDeps = [
2021-05-20 23:08:51 +00:00
gtk3 atk pango . out gdk-pixbuf harfbuzz
2020-04-24 23:36:52 +00:00
] ;
2024-01-13 08:15:51 +00:00
in stdenv . mkDerivation ( finalAttrs : {
2020-04-24 23:36:52 +00:00
pname = " g j s " ;
2024-05-15 15:35:15 +00:00
version = " 1 . 8 0 . 2 " ;
2021-05-20 23:08:51 +00:00
outputs = [ " o u t " " d e v " " i n s t a l l e d T e s t s " ] ;
2020-04-24 23:36:52 +00:00
src = fetchurl {
2024-01-13 08:15:51 +00:00
url = " m i r r o r : / / g n o m e / s o u r c e s / g j s / ${ lib . versions . majorMinor finalAttrs . version } / g j s - ${ finalAttrs . version } . t a r . x z " ;
2024-05-15 15:35:15 +00:00
hash = " s h a 2 5 6 - E 1 4 5 x a x Z E J Y j P l V 8 / l d 9 Z A k / U F R B H U f L L i F L r X 1 B m b 0 = " ;
2020-04-24 23:36:52 +00:00
} ;
2021-05-20 23:08:51 +00:00
patches = [
# Hard-code various paths
./fix-paths.patch
# Allow installing installed tests to a separate output.
./installed-tests-path.patch
2024-05-15 15:35:15 +00:00
# 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
2021-05-20 23:08:51 +00:00
] ;
2020-04-24 23:36:52 +00:00
nativeBuildInputs = [
meson
ninja
2021-02-05 17:12:51 +00:00
pkg-config
2020-04-24 23:36:52 +00:00
makeWrapper
2020-06-18 07:06:33 +00:00
which # for locale detection
2020-04-24 23:36:52 +00:00
libxml2 # for xml-stripblanks
2022-09-30 11:47:45 +00:00
dbus # for dbus-run-session
gobject-introspection
] ++ lib . optionals ( ! stdenv . buildPlatform . canExecute stdenv . hostPlatform ) [
mesonEmulatorHook
2020-04-24 23:36:52 +00:00
] ;
buildInputs = [
cairo
readline
2022-07-14 12:49:19 +00:00
libsysprof-capture
2024-01-02 11:29:13 +00:00
spidermonkey_115
2020-04-24 23:36:52 +00:00
] ;
2023-02-02 18:25:31 +00:00
nativeCheckInputs = [
2021-05-20 23:08:51 +00:00
xvfb-run
2020-04-24 23:36:52 +00:00
] ++ testDeps ;
propagatedBuildInputs = [
glib
] ;
mesonFlags = [
" - D i n s t a l l e d _ t e s t _ p r e f i x = ${ placeholder " i n s t a l l e d T e s t s " } "
2022-12-02 08:20:57 +00:00
] ++ lib . optionals ( ! stdenv . isLinux || stdenv . hostPlatform . isMusl ) [
2022-10-21 18:38:19 +00:00
" - D p r o f i l e r = d i s a b l e d "
2020-04-24 23:36:52 +00:00
] ;
2022-10-21 18:38:19 +00:00
doCheck = ! stdenv . isDarwin ;
2020-04-24 23:36:52 +00:00
postPatch = ''
2020-06-18 07:06:33 +00:00
patchShebangs build/choose-tests-locale.sh
2020-04-24 23:36:52 +00:00
substituteInPlace installed-tests/debugger-test.sh - - subst-var-by gjsConsole $ out/bin/gjs-console
2022-12-02 08:20:57 +00:00
'' + l i b . o p t i o n a l S t r i n g s t d e n v . h o s t P l a t f o r m . i s M u s l ''
substituteInPlace installed-tests/js/meson.build \
- - replace " ' E n c o d i n g ' , " " # ' E n c o d i n g ' , "
2020-04-24 23:36:52 +00:00
'' ;
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.
2020-11-12 09:05:59 +00:00
mkdir - p $ out/lib $ installedTests/libexec/installed-tests/gjs
2020-04-24 23:36:52 +00:00
ln - s $ PWD/libgjs.so.0 $ out/lib/libgjs.so.0
2020-11-12 09:05:59 +00:00
ln - s $ PWD/installed-tests/js/libgimarshallingtests.so $ installedTests/libexec/installed-tests/gjs/libgimarshallingtests.so
2021-05-20 23:08:51 +00:00
ln - s $ PWD/installed-tests/js/libgjstesttools/libgjstesttools.so $ installedTests/libexec/installed-tests/gjs/libgjstesttools.so
2020-11-12 09:05:59 +00:00
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
2020-04-24 23:36:52 +00:00
'' ;
postInstall = ''
2020-11-12 09:05:59 +00:00
# TODO: make the glib setup hook handle moving the schemas in other outputs.
2024-01-13 08:15:51 +00:00
installedTestsSchemaDatadir = " $ i n s t a l l e d T e s t s / s h a r e / g s e t t i n g s - s c h e m a s / g j s - ${ finalAttrs . version } "
2020-06-18 07:06:33 +00:00
mkdir - p " $ i n s t a l l e d T e s t s S c h e m a D a t a d i r "
mv " $ i n s t a l l e d T e s t s / s h a r e / g l i b - 2 . 0 " " $ i n s t a l l e d T e s t s S c h e m a D a t a d i r "
'' ;
2024-01-13 08:15:51 +00:00
postFixup = lib . optionalString installTests ''
2020-11-12 09:05:59 +00:00
wrapProgram " $ i n s t a l l e d T e s t s / l i b e x e c / i n s t a l l e d - t e s t s / g j s / m i n i j a s m i n e " \
2020-06-18 07:06:33 +00:00
- - prefix XDG_DATA_DIRS : " $ i n s t a l l e d T e s t s S c h e m a D a t a d i r " \
2021-02-05 17:12:51 +00:00
- - prefix GI_TYPELIB_PATH : " ${ lib . makeSearchPath " l i b / g i r e p o s i t o r y - 1 . 0 " testDeps } "
2020-04-24 23:36:52 +00:00
'' ;
checkPhase = ''
runHook preCheck
xvfb-run - s ' - screen 0 8 0 0 x600x24' \
meson test - - print-errorlogs
runHook postCheck
'' ;
separateDebugInfo = stdenv . isLinux ;
passthru = {
tests = {
installed-tests = nixosTests . installed-tests . gjs ;
} ;
2021-05-20 23:08:51 +00:00
updateScript = gnome . updateScript {
2020-04-24 23:36:52 +00:00
packageName = " g j s " ;
2021-08-10 14:31:46 +00:00
versionPolicy = " o d d - u n s t a b l e " ;
2020-04-24 23:36:52 +00:00
} ;
} ;
2021-02-05 17:12:51 +00:00
meta = with lib ; {
2020-04-24 23:36:52 +00:00
description = " J a v a S c r i p t b i n d i n g s f o r G N O M E " ;
homepage = " h t t p s : / / g i t l a b . g n o m e . o r g / G N O M E / g j s / b l o b / m a s t e r / d o c / H o m e . m d " ;
license = licenses . lgpl2Plus ;
maintainers = teams . gnome . members ;
2022-10-21 18:38:19 +00:00
platforms = platforms . unix ;
2020-04-24 23:36:52 +00:00
} ;
2024-01-13 08:15:51 +00:00
} )