nix: use wrapGAppsHook (#116)

This commit is contained in:
Aylur
2023-10-03 23:52:24 +02:00
committed by GitHub
parent 991c23c463
commit 417f440d63
13 changed files with 184 additions and 287 deletions

View File

@@ -5,10 +5,7 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = {
nixpkgs,
self,
}: let
outputs = { nixpkgs, self }: let
genSystems = nixpkgs.lib.genAttrs [
"aarch64-linux"
"x86_64-linux"
@@ -16,10 +13,9 @@
pkgs = genSystems (system: import nixpkgs {inherit system;});
in {
packages = genSystems (system: {
default = pkgs.${system}.callPackage ./nix/ags.nix {
gjs = pkgs.${system}.callPackage ./nix/gjs.nix {};
};
default = pkgs.${system}.callPackage ./nix {};
});
homeManagerModules.default = import ./nix/hm-module.nix self;
};
}

View File

@@ -1,12 +1,19 @@
project('ags',
project('ags', 'c',
version: '1.3.0',
meson_version: '>= 0.62.0',
license: ['GPL-3.0-or-later'],
default_options: [ 'warning_level=2', 'werror=false', ],
)
APP = meson.project_name()
app_id = 'com.github.Aylur.ags'
prefix = get_option('prefix')
libdir = join_paths(prefix, get_option('libdir'))
extensiondir = join_paths(libdir, meson.project_name())
datadir = join_paths(prefix, get_option('datadir'))
pkgdatadir = join_paths(datadir, app_id)
bindir = join_paths(prefix, get_option('bindir'))
dependency('glib-2.0')
dependency('gobject-introspection-1.0', version: '>= 1.49.1')
dependency('gio-2.0', version: '>= 2.56.0')
dependency('gjs-1.0', version: '>= 1.73.1')
@@ -14,9 +21,9 @@ dependency('gtk+-3.0', version: '>= 3.0')
subproject('gvc',
default_options: [
'package_name=' + APP,
'pkgdatadir=' + get_option('datadir') / APP,
'pkglibdir=' + get_option('libdir') / APP,
'package_name=' + app_id,
'pkgdatadir=' + pkgdatadir,
'pkglibdir=' + libdir,
'static=false',
'introspection=true',
'alsa=false'
@@ -24,3 +31,11 @@ subproject('gvc',
)
subdir('src')
meson.add_install_script(
'meson_post_install.py',
datadir,
pkgdatadir,
bindir,
app_id
)

18
meson_post_install.py Normal file
View File

@@ -0,0 +1,18 @@
#!/usr/bin/env python3
import os
import subprocess
import sys
destdir = os.environ.get('DESTDIR', '')
datadir = sys.argv[1]
pkgdatadir = sys.argv[2]
bindir = os.path.join(destdir + os.sep + sys.argv[3])
app_id = sys.argv[4]
if not os.path.exists(bindir):
os.makedirs(bindir)
src = os.path.join(pkgdatadir, app_id)
dest = os.path.join(bindir, 'ags')
subprocess.call(['ln', '-s', '-f', src, dest])

View File

@@ -10,6 +10,15 @@
, gtk3
, libpulseaudio
, gjs
, python3
, wrapGAppsHook
, upower
, gnome
, gtk-layer-shell
, glib-networking
, networkmanager
, libdbusmenu-gtk3
, gvfs
}:
let
@@ -53,22 +62,32 @@ stdenv.mkDerivation {
cp -r ${gi-types-src}/* ./gi-types
'';
patches = [
./gvc-path.patch
];
postPatch = ''
chmod +x meson_post_install.py
patchShebangs meson_post_install.py
'';
nativeBuildInputs = [
nodePackages.typescript
meson
pkg-config
meson
ninja
nodePackages.typescript
python3
wrapGAppsHook
gobject-introspection
];
buildInputs = [
gobject-introspection
gjs
gtk3
libpulseaudio
upower
gnome.gnome-bluetooth
gtk-layer-shell
glib-networking
networkmanager
libdbusmenu-gtk3
gvfs
];
meta = with lib; {

View File

@@ -1,13 +0,0 @@
diff --git a/installed-tests/debugger-test.sh b/installed-tests/debugger-test.sh
index 0d118490..54c5507e 100755
--- a/installed-tests/debugger-test.sh
+++ b/installed-tests/debugger-test.sh
@@ -3,7 +3,7 @@
if test "$GJS_USE_UNINSTALLED_FILES" = "1"; then
gjs="$TOP_BUILDDIR/gjs-console"
else
- gjs=gjs-console
+ gjs=@gjsConsole@
fi
echo 1..1

View File

@@ -1,165 +0,0 @@
{ fetchurl
, lib
, stdenv
, meson
, mesonEmulatorHook
, ninja
, pkg-config
, gnome
, gtk3
, atk
, gobject-introspection
, spidermonkey_102
, pango
, cairo
, readline
, libsysprof-capture
, glib
, libxml2
, dbus
, gdk-pixbuf
, networkmanager
, harfbuzz
, makeWrapper
, wrapGAppsHook
, which
, xvfb-run
, nixosTests
, upower
, glib-networking
, gtk-layer-shell
, libdbusmenu-gtk3
, libsoup_3
, gvfs
}:
let
testDeps = [
gtk3 atk pango.out gdk-pixbuf harfbuzz
];
in stdenv.mkDerivation rec {
pname = "gjs";
version = "1.76.2";
outputs = [ "out" "dev" "installedTests" ];
src = fetchurl {
url = "mirror://gnome/sources/gjs/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
sha256 = "sha256-99jJ1lPqb9eK/kpQcg4EaqK/wHj9pjXdEwZ90ZnGJdQ=";
};
patches = [
# Hard-code various paths
./fix-paths.patch
# Allow installing installed tests to a separate output.
./installed-tests-path.patch
];
nativeBuildInputs = [
meson
ninja
pkg-config
makeWrapper
wrapGAppsHook
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
upower
gnome.gnome-bluetooth
gtk-layer-shell
glib-networking
networkmanager
readline
libsysprof-capture
spidermonkey_102
libdbusmenu-gtk3
libsoup_3
gvfs
];
nativeCheckInputs = [
xvfb-run
] ++ testDeps;
propagatedBuildInputs = [
glib
];
mesonFlags = [
"-Dinstalled_test_prefix=${placeholder "installedTests"}"
] ++ lib.optionals (!stdenv.isLinux || stdenv.hostPlatform.isMusl) [
"-Dprofiler=disabled"
];
doCheck = !stdenv.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/${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
'';
separateDebugInfo = stdenv.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;
};
}

View File

@@ -1,26 +0,0 @@
diff --git a/meson.build b/meson.build
index 63b3e6d..62fc8b8 100644
--- a/meson.build
+++ b/meson.build
@@ -16,7 +16,7 @@ subproject('gvc',
default_options: [
'package_name=' + APP,
'pkgdatadir=' + get_option('datadir') / APP,
- 'pkglibdir=' + get_option('libdir') / APP,
+ 'pkglibdir=' + get_option('libdir'),
'static=false',
'introspection=true',
'alsa=false'
diff --git a/src/meson.build b/src/meson.build
index 44ee0a5..d96615a 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -27,7 +27,7 @@ app_launcher = configure_file(
output : APP,
configuration: {
'GJS': find_program('gjs').full_path(),
- 'GVC_GIR': get_option('prefix') / get_option('libdir') / APP,
+ 'GVC_GIR': get_option('prefix') / get_option('libdir'),
'PACKAGE_NAME': APP,
'PACKAGE_VERSION': meson.project_version(),
'PREFIX': get_option('prefix'),

View File

@@ -1,37 +0,0 @@
diff --git a/installed-tests/meson.build b/installed-tests/meson.build
index 04c7910f..9647908c 100644
--- a/installed-tests/meson.build
+++ b/installed-tests/meson.build
@@ -1,7 +1,7 @@
### Installed tests ############################################################
-installed_tests_execdir = get_option('prefix') / get_option('libexecdir') / 'installed-tests' / meson.project_name()
-installed_tests_metadir = abs_datadir / 'installed-tests' / meson.project_name()
+installed_tests_execdir = get_option('installed_test_prefix') / 'libexec' / 'installed-tests' / meson.project_name()
+installed_tests_metadir = get_option('installed_test_prefix') / 'share' / 'installed-tests' / meson.project_name()
# Simple shell script tests #
diff --git a/meson.build b/meson.build
index 9ab29475..42ffe07f 100644
--- a/meson.build
+++ b/meson.build
@@ -557,7 +557,7 @@ install_data('installed-tests/extra/lsan.supp',
install_dir: get_option('datadir') / api_name / 'lsan')
if get_option('installed_tests')
- schemadir = abs_datadir / 'glib-2.0' / 'schemas'
+ schemadir = get_option('installed_test_prefix') / 'share' / 'glib-2.0' / 'schemas'
install_data('installed-tests/js/org.gnome.GjsTest.gschema.xml', install_dir: schemadir)
meson.add_install_script('build/compile-gschemas.py', schemadir)
endif
diff --git a/meson_options.txt b/meson_options.txt
index 825ba77a..21f0323c 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -25,3 +25,5 @@ option('skip_gtk_tests', type: 'boolean', value: false,
description: 'Skip tests that need a display connection')
option('verbose_logs', type: 'boolean', value: false,
description: 'Enable extra log messages that may decrease performance (not allowed in release builds)')
+option('installed_test_prefix', type: 'string', value: '',
+ description: 'Prefix for installed tests')

37
src/com.github.Aylur.ags.js.in Executable file
View File

@@ -0,0 +1,37 @@
#!@GJS@ -m
/*
* Copyright 2023 Aylur@github
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { exit, programArgs, programInvocationName } from "system";
imports.package.init({
name: '@APP_ID@',
version: '@PACKAGE_VERSION@',
prefix: '@PREFIX@',
libdir: '@LIBDIR@',
});
const { Repository } = imports.gi.GIRepository;
Repository.prepend_search_path('@LIBDIR@');
Repository.prepend_library_path('@LIBDIR@');
const module = await import('resource://@RESOURCE_PATH@/main.js');
const exitCode = await module.main([programInvocationName, ...programArgs]);
exit(exitCode);

View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/com/github/Aylur/ags">
<file>app.js</file>
<file>client.js</file>
<file>main.js</file>
<file>service.js</file>
<file>utils.js</file>
<file>variable.js</file>
<file>widget.js</file>
<file>widgets/constructor.js</file>
<file>widgets/overrides.js</file>
<file>widgets/box.js</file>
<file>widgets/button.js</file>
<file>widgets/centerbox.js</file>
<file>widgets/circularprogress.js</file>
<file>widgets/entry.js</file>
<file>widgets/eventbox.js</file>
<file>widgets/icon.js</file>
<file>widgets/label.js</file>
<file>widgets/menu.js</file>
<file>widgets/overlay.js</file>
<file>widgets/progressbar.js</file>
<file>widgets/revealer.js</file>
<file>widgets/scrollable.js</file>
<file>widgets/slider.js</file>
<file>widgets/stack.js</file>
<file>widgets/window.js</file>
<file>service/service.js</file>
<file>service/applications.js</file>
<file>service/audio.js</file>
<file>service/battery.js</file>
<file>service/bluetooth.js</file>
<file>service/hyprland.js</file>
<file>service/mpris.js</file>
<file>service/network.js</file>
<file>service/notifications.js</file>
<file>service/systemtray.js</file>
<file>dbus/types.js</file>
<file>dbus/com.github.Aylur.ags.xml</file>
<file>dbus/com.github.Aylur.ags.client.xml</file>
<file>dbus/org.freedesktop.DBus.xml</file>
<file>dbus/org.freedesktop.Notifications.xml</file>
<file>dbus/org.freedesktop.UPower.Device.xml</file>
<file>dbus/org.mpris.MediaPlayer2.Player.xml</file>
<file>dbus/org.mpris.MediaPlayer2.xml</file>
<file>dbus/org.kde.StatusNotifierWatcher.xml</file>
<file>dbus/org.kde.StatusNotifierItem.xml</file>
</gresource>
</gresources>

View File

@@ -7,9 +7,10 @@ import Service from './service.js';
import Variable from './variable.js';
import Widget from './widget.js';
const APP_BUS = (name: string) => 'com.github.Aylur.ags.' + name;
const APP_PATH = (name: string) => '/com/github/Aylur/ags/' + name;
const DEFAULT_CONF = `${GLib.get_user_config_dir()}/${pkg.name}/config.js`;
const BIN_NAME = pkg.name.split('.').pop() as string;
const APP_BUS = (name: string) => `${pkg.name}.${name}`;
const APP_PATH = (name: string) => `/${pkg.name.split('.').join('/')}/${name}`;
const DEFAULT_CONF = `${GLib.get_user_config_dir()}/${BIN_NAME}/config.js`;
const help = (bin: string) => `USAGE:
${bin} [OPTIONS]
@@ -51,7 +52,7 @@ function isRunning(dbusName: string) {
export function main(args: string[]) {
const flags = {
busName: pkg.name,
busName: BIN_NAME,
config: DEFAULT_CONF,
inspector: false,
runJs: '',

View File

@@ -10,31 +10,29 @@ typescript = custom_target(
output: ['tsc-output'],
)
# launcher binary
configure_file(
input : app_id + '.js.in',
output : app_id,
configuration: {
'GJS': find_program('gjs').full_path(),
'APP_ID': app_id,
'PACKAGE_VERSION': meson.project_version(),
'PREFIX': prefix,
'LIBDIR': libdir,
'RESOURCE_PATH': '/com/github/Aylur/ags',
},
install: true,
install_dir: pkgdatadir
)
# gresource
src_res = import('gnome').compile_resources(
APP + '.src',
APP + '.src.gresource.xml',
import('gnome').compile_resources(
app_id + '.src',
app_id + '.src.gresource.xml',
dependencies: typescript,
source_dir: tsc_out,
gresource_bundle: true,
install: true,
install_dir : get_option('datadir') / APP
)
# launcher binary
app_launcher = configure_file(
input : APP + '.js.in',
output : APP,
configuration: {
'GJS': find_program('gjs').full_path(),
'GVC_GIR': get_option('prefix') / get_option('libdir') / APP,
'PACKAGE_NAME': APP,
'PACKAGE_VERSION': meson.project_version(),
'PREFIX': get_option('prefix'),
'LIBDIR': get_option('prefix') / get_option('libdir'),
'RESOURCE_PATH': '/com/github/Aylur/' + APP,
},
install: true,
install_dir: get_option('bindir'),
install_mode: 'rwxr-xr-x'
install_dir : pkgdatadir
)

View File

@@ -4,8 +4,9 @@ import GLib from 'gi://GLib';
import GObject from 'gi://GObject';
import { Command } from './widgets/constructor.js';
export const USER = GLib.get_user_name();
export const CACHE_DIR = `${GLib.get_user_cache_dir()}/${pkg.name}`;
export const CACHE_DIR = `${GLib.get_user_cache_dir()}/${pkg.name.split('.').pop()}`;
export function readFile(path: string) {
const f = Gio.File.new_for_path(path);