1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 replaceVars,
6 openssl,
7 gsound,
8 meson,
9 ninja,
10 pkg-config,
11 gobject-introspection,
12 wrapGAppsHook3,
13 glib,
14 glib-networking,
15 gtk3,
16 openssh,
17 gnome-shell,
18 evolution-data-server-gtk4,
19 gjs,
20 nixosTests,
21 desktop-file-utils,
22}:
23
24stdenv.mkDerivation rec {
25 pname = "gnome-shell-extension-gsconnect";
26 version = "62";
27
28 outputs = [
29 "out"
30 "installedTests"
31 ];
32
33 src = fetchFromGitHub {
34 owner = "GSConnect";
35 repo = "gnome-shell-extension-gsconnect";
36 rev = "v${version}";
37 hash = "sha256-HFm04XC61AjkJSt4YBc4dO9v563w+LsYDSaZckPYE14=";
38 };
39
40 patches = [
41 # Make typelibs available in the extension
42 (replaceVars ./fix-paths.patch {
43 gapplication = "${glib.bin}/bin/gapplication";
44 # Replaced in postPatch
45 typelibPath = null;
46 })
47
48 # Allow installing installed tests to a separate output
49 ./installed-tests-path.patch
50 ];
51
52 nativeBuildInputs = [
53 meson
54 ninja
55 pkg-config
56 gobject-introspection # for locating typelibs
57 wrapGAppsHook3 # for wrapping daemons
58 desktop-file-utils # update-desktop-database
59 ];
60
61 buildInputs = [
62 glib # libgobject
63 glib-networking
64 gtk3
65 gsound
66 gjs # for running daemon
67 evolution-data-server-gtk4 # for libebook-contacts typelib
68 ];
69
70 mesonFlags = [
71 "-Dgnome_shell_libdir=${gnome-shell}/lib"
72 "-Dchrome_nmhdir=${placeholder "out"}/etc/opt/chrome/native-messaging-hosts"
73 "-Dchromium_nmhdir=${placeholder "out"}/etc/chromium/native-messaging-hosts"
74 "-Dopenssl_path=${openssl}/bin/openssl"
75 "-Dsshadd_path=${openssh}/bin/ssh-add"
76 "-Dsshkeygen_path=${openssh}/bin/ssh-keygen"
77 "-Dsession_bus_services_dir=${placeholder "out"}/share/dbus-1/services"
78 "-Dinstalled_test_prefix=${placeholder "installedTests"}"
79 ];
80
81 postPatch = ''
82 patchShebangs installed-tests/prepare-tests.sh
83
84 # TODO: do not include every typelib everywhere
85 # for example, we definitely do not need nautilus
86 substituteInPlace src/__nix-prepend-search-paths.js \
87 --subst-var-by typelibPath "$GI_TYPELIB_PATH"
88
89 # slightly janky fix for gsettings_schemadir being removed
90 substituteInPlace data/config.js.in \
91 --subst-var-by GSETTINGS_SCHEMA_DIR ${glib.makeSchemaPath (placeholder "out") "${pname}-${version}"}
92 '';
93
94 postFixup = ''
95 # Let’s wrap the daemons
96 for file in $out/share/gnome-shell/extensions/gsconnect@andyholmes.github.io/service/{daemon,nativeMessagingHost}.js; do
97 echo "Wrapping program $file"
98 wrapGApp "$file"
99 done
100
101 # Wrap jasmine runner for tests
102 for file in $installedTests/libexec/installed-tests/gsconnect/minijasmine; do
103 echo "Wrapping program $file"
104 wrapGApp "$file"
105 done
106 '';
107
108 passthru = {
109 extensionUuid = "gsconnect@andyholmes.github.io";
110 extensionPortalSlug = "gsconnect";
111 };
112
113 passthru = {
114 tests = {
115 installedTests = nixosTests.installed-tests.gsconnect;
116 };
117 };
118
119 meta = with lib; {
120 description = "KDE Connect implementation for Gnome Shell";
121 homepage = "https://github.com/GSConnect/gnome-shell-extension-gsconnect/wiki";
122 license = licenses.gpl2Plus;
123 maintainers = [ maintainers.doronbehar ];
124 teams = [ teams.gnome ];
125 platforms = platforms.linux;
126 };
127}