nixpkgs/pkgs/development/libraries/gjs/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

149 lines
3.9 KiB
Nix
Raw Normal View History

2019-11-05 02:49:38 +03:00
{ fetchurl
2021-05-06 20:32:27 +03:00
, lib
, stdenv
, meson
2022-08-07 01:48:42 +03:00
, mesonEmulatorHook
, ninja
, pkg-config
, gnome
2019-11-05 02:49:38 +03:00
, gtk3
, atk
, gobject-introspection
, spidermonkey_102
2019-11-05 02:49:38 +03:00
, pango
, cairo
2019-11-05 02:49:38 +03:00
, readline
, libsysprof-capture
2019-11-05 02:49:38 +03:00
, glib
, libxml2
, dbus
, gdk-pixbuf
, harfbuzz
2019-11-05 02:49:38 +03:00
, makeWrapper
, which
2021-05-08 16:45:03 +03:00
, xvfb-run
, nixosTests
2019-11-05 02:49:38 +03:00
}:
let
testDeps = [
gtk3 atk pango.out gdk-pixbuf harfbuzz
];
in stdenv.mkDerivation rec {
pname = "gjs";
version = "1.76.0";
2021-05-06 20:32:27 +03:00
outputs = [ "out" "dev" "installedTests" ];
src = fetchurl {
url = "mirror://gnome/sources/gjs/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
sha256 = "sha256-pj8VaWSxNgU+q1HqATEU59fBk7dRjSjAQLawLDyTOm0=";
};
patches = [
# Hard-code various paths
./fix-paths.patch
# Allow installing installed tests to a separate output.
./installed-tests-path.patch
];
2019-11-05 02:49:38 +03:00
nativeBuildInputs = [
meson
ninja
pkg-config
2019-11-05 02:49:38 +03:00
makeWrapper
which # for locale detection
libxml2 # for xml-stripblanks
2022-08-07 01:48:42 +03:00
dbus # for dbus-run-session
gobject-introspection
] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
mesonEmulatorHook
2019-11-05 02:49:38 +03:00
];
buildInputs = [
cairo
2019-11-05 02:49:38 +03:00
readline
libsysprof-capture
spidermonkey_102
2019-11-05 02:49:38 +03:00
];
nativeCheckInputs = [
2021-05-08 16:45:03 +03:00
xvfb-run
] ++ testDeps;
2019-11-05 02:49:38 +03:00
propagatedBuildInputs = [
glib
2019-11-05 02:49:38 +03:00
];
mesonFlags = [
"-Dinstalled_test_prefix=${placeholder "installedTests"}"
2022-11-27 21:10:33 +03:00
] ++ lib.optionals (!stdenv.isLinux || stdenv.hostPlatform.isMusl) [
2022-10-17 22:09:04 +03:00
"-Dprofiler=disabled"
];
2022-10-17 22:09:04 +03:00
doCheck = !stdenv.isDarwin;
2018-02-15 00:19:56 +03:00
postPatch = ''
patchShebangs build/choose-tests-locale.sh
substituteInPlace installed-tests/debugger-test.sh --subst-var-by gjsConsole $out/bin/gjs-console
2022-11-27 21:10:33 +03:00
'' + lib.optionalString stdenv.hostPlatform.isMusl ''
substituteInPlace installed-tests/js/meson.build \
--replace "'Encoding'," "#'Encoding',"
2018-02-15 00:19:56 +03: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.
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
2021-05-06 20:32:27 +03:00
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
'';
2018-02-15 00:19:56 +03:00
postInstall = ''
# TODO: make the glib setup hook handle moving the schemas in other outputs.
installedTestsSchemaDatadir="$installedTests/share/gsettings-schemas/${pname}-${version}"
mkdir -p "$installedTestsSchemaDatadir"
mv "$installedTests/share/glib-2.0" "$installedTestsSchemaDatadir"
'';
postFixup = ''
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
'';
2019-11-05 02:51:07 +03:00
separateDebugInfo = stdenv.isLinux;
2019-11-05 02:49:38 +03:00
passthru = {
tests = {
installed-tests = nixosTests.installed-tests.gjs;
};
updateScript = gnome.updateScript {
2019-11-05 02:49:38 +03:00
packageName = "gjs";
2021-08-10 12:10:15 +03:00
versionPolicy = "odd-unstable";
2019-11-05 02:49:38 +03:00
};
};
meta = with lib; {
2018-02-14 23:28:44 +03:00
description = "JavaScript bindings for GNOME";
2019-11-05 02:49:38 +03:00
homepage = "https://gitlab.gnome.org/GNOME/gjs/blob/master/doc/Home.md";
license = licenses.lgpl2Plus;
maintainers = teams.gnome.members;
2022-10-17 22:09:04 +03:00
platforms = platforms.unix;
};
}