From 4c1bfb83b0921600f589dc32ca62df12af8d4c64 Mon Sep 17 00:00:00 2001 From: wxt <3264117476@qq.com> Date: Thu, 21 Nov 2024 17:38:24 +0800 Subject: [PATCH] biblioteca: init at 1.5 --- .../bi/biblioteca/dont-use-flatpak.patch | 38 +++++++ pkgs/by-name/bi/biblioteca/package.nix | 104 ++++++++++++++++++ pkgs/top-level/all-packages.nix | 4 + 3 files changed, 146 insertions(+) create mode 100644 pkgs/by-name/bi/biblioteca/dont-use-flatpak.patch create mode 100644 pkgs/by-name/bi/biblioteca/package.nix diff --git a/pkgs/by-name/bi/biblioteca/dont-use-flatpak.patch b/pkgs/by-name/bi/biblioteca/dont-use-flatpak.patch new file mode 100644 index 0000000000000..17660c3b0a091 --- /dev/null +++ b/pkgs/by-name/bi/biblioteca/dont-use-flatpak.patch @@ -0,0 +1,38 @@ +From 46a92740dde0372fbe3e75a9a334ea79b6f53da1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ball=C3=B3=20Gy=C3=B6rgy?= +Date: Fri, 8 Nov 2024 00:04:01 +0100 +Subject: [PATCH] Don't check if running under Flatpak + +--- + src/bin.js | 8 -------- + 1 file changed, 8 deletions(-) + +diff --git a/src/bin.js b/src/bin.js +index 5dcc3eb..362ce67 100755 +--- a/src/bin.js ++++ b/src/bin.js +@@ -3,7 +3,6 @@ + import { exit, programArgs } from "system"; + import GLib from "gi://GLib"; + import { setConsoleLogDomain } from "console"; +-import Xdp from "gi://Xdp"; + + // eslint-disable-next-line no-restricted-globals + imports.package.init({ +@@ -16,13 +15,6 @@ imports.package.init({ + setConsoleLogDomain(pkg.name); + GLib.set_application_name("Biblioteca"); + +-if (!Xdp.Portal.running_under_flatpak()) { +- console.error( +- "Flatpak required\nBiblioteca is only meant to be run sandboxed in a specific target environment.\nBypassing this will exposes users to arbitrary code breakage.", +- ); +- exit(1); +-} +- + globalThis.__DEV__ = pkg.name.endsWith(".Devel"); + if (__DEV__) { + pkg.sourcedir = "@sourcedir@"; +-- +2.47.0 + diff --git a/pkgs/by-name/bi/biblioteca/package.nix b/pkgs/by-name/bi/biblioteca/package.nix new file mode 100644 index 0000000000000..0224fdb45a693 --- /dev/null +++ b/pkgs/by-name/bi/biblioteca/package.nix @@ -0,0 +1,104 @@ +{ + stdenv, + lib, + fetchFromGitHub, + meson, + ninja, + desktop-file-utils, + glib, + gjs, + blueprint-compiler, + pkg-config, + gtk4, + gobject-introspection, + libadwaita, + webkitgtk, + coreutils, + makeShellWrapper, + wrapGAppsHook4, + glib-networking, + symlinkJoin, + extraDocsPackage ? [ ], +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "biblioteca"; + version = "1.5"; + + src = fetchFromGitHub { + owner = "workbenchdev"; + repo = "Biblioteca"; + rev = "refs/tags/v${finalAttrs.version}"; + fetchSubmodules = true; + hash = "sha256-zrrI3u4ukGN6eb/eK/aZG4gi/xtXciyRS+JX9Js9KEw="; + }; + + patches = [ + ./dont-use-flatpak.patch # From https://gitlab.archlinux.org/archlinux/packaging/packages/biblioteca/-/blob/main/biblioteca-no-flatpak.patch?ref_type=heads + ]; + + nativeBuildInputs = [ + meson + ninja + desktop-file-utils + makeShellWrapper + gjs + wrapGAppsHook4 + pkg-config + ]; + + buildInputs = [ + glib + gtk4 + gobject-introspection + libadwaita + webkitgtk + glib-networking + ]; + + docPath = symlinkJoin { + name = "biblioteca-docs"; + paths = [ + gtk4.devdoc + glib.devdoc + libadwaita.devdoc + webkitgtk.devdoc + gobject-introspection.devdoc + ] ++ extraDocsPackage; + }; + + postPatch = '' + substituteInPlace src/meson.build \ + --replace-fail "/app/bin/blueprint-compiler" "${lib.getExe blueprint-compiler}" \ + + patchShebangs . + + substituteInPlace build-aux/build-index.js \ + --replace-fail "/usr/bin/env -S gjs -m" "${coreutils}/bin/env -S ${gjs}/bin/gjs -m" \ + --replace-fail "/app/share/doc" "${finalAttrs.docPath}/share/doc" + + substituteInPlace src/Shortcuts.js \ + --replace-fail "/app/share/doc" "${finalAttrs.docPath}/share/doc" + substituteInPlace src/window.blp \ + --replace-fail "/app/share/doc" "${finalAttrs.docPath}/share/doc" + substituteInPlace src/window.js \ + --replace-fail "/app/share/doc" "${finalAttrs.docPath}/share/doc" + ''; + + postInstall = '' + mv $out/bin/app.drey.Biblioteca $out/share/app.drey.Biblioteca/app.drey.Biblioteca + substituteInPlace $out/bin/biblioteca \ + --replace-fail app.drey.Biblioteca $out/share/app.drey.Biblioteca/app.drey.Biblioteca + ''; + + doCheck = true; + + meta = { + homepage = "https://apps.gnome.org/Biblioteca/"; + platforms = lib.platforms.linux; + maintainers = with lib.maintainers; [ bot-wxt1221 ]; + license = lib.licenses.gpl3Only; + description = "Documentation viewer for GNOME"; + mainProgram = "biblioteca"; + }; +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8e81e5a54b2eb..ab74d14798085 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -19208,4 +19208,8 @@ with pkgs; tree-from-tags = callPackage ../by-name/tr/tree-from-tags/package.nix { ruby = ruby_3_1; }; + + biblioteca = callPackage ../by-name/bi/biblioteca/package.nix { + webkitgtk = webkitgtk_6_0; + }; }