1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 appstream-glib,
6 blueprint-compiler,
7 desktop-file-utils,
8 gobject-introspection,
9 meson,
10 ninja,
11 pkg-config,
12 wrapGAppsHook4,
13 gjs,
14 gtk4,
15 libadwaita,
16 libportal-gtk4,
17 nix-update-script,
18}:
19
20stdenv.mkDerivation rec {
21 pname = "junction";
22 version = "1.9";
23
24 src = fetchFromGitHub {
25 owner = "sonnyp";
26 repo = "junction";
27 rev = "v${version}";
28 hash = "sha256-gnFig8C46x73gAUl9VVx3Y3hrhEVeP/DvaYHYuv9RTg=";
29 fetchSubmodules = true;
30 };
31
32 nativeBuildInputs = [
33 appstream-glib
34 blueprint-compiler
35 desktop-file-utils
36 gobject-introspection
37 meson
38 ninja
39 pkg-config
40 wrapGAppsHook4
41 ];
42
43 buildInputs = [
44 gjs
45 gtk4
46 libadwaita
47 libportal-gtk4
48 ];
49
50 postPatch = ''
51 # gjs uses the invocation name to add gresource files
52 # - https://gitlab.gnome.org/GNOME/gjs/-/blob/6aca7b50785fa1638f144b17060870d721e3f65a/modules/script/package.js#L159
53 # - https://gitlab.gnome.org/GNOME/gjs/-/blob/6aca7b50785fa1638f144b17060870d721e3f65a/modules/script/package.js#L37
54 # To work around this, we manually set the the name as done in foliate
55 # - https://github.com/NixOS/nixpkgs/blob/3bacde6273b09a21a8ccfba15586fb165078fb62/pkgs/applications/office/foliate/default.nix#L23
56 sed -i "1 a imports.package._findEffectiveEntryPointName = () => 're.sonny.Junction';" src/bin.js
57
58 # /usr/bin/env is not accessible in build environment
59 substituteInPlace troll/gjspack/bin/gjspack --replace "/usr/bin/env -S gjs" "${gjs}/bin/gjs"
60 '';
61
62 postInstall = ''
63 # autoPatchShebangs does not like "/usr/bin/env -S <environment-setting> gjs -m"
64 sed -i "1s|.*|#!/usr/bin/gjs -m|" $out/bin/re.sonny.Junction
65 '';
66
67 passthru = {
68 updateScript = nix-update-script { };
69 };
70
71 meta = with lib; {
72 mainProgram = "re.sonny.Junction";
73 description = "Choose the application to open files and links";
74 homepage = "https://apps.gnome.org/Junction/";
75 license = licenses.gpl3Only;
76 maintainers = with maintainers; [ hqurve ];
77 teams = [ teams.gnome-circle ];
78 platforms = platforms.linux;
79 };
80}