From 31b29e03d1a14fed0811499f7b9885d0a1911d97 Mon Sep 17 00:00:00 2001 From: Danilo Reyes Date: Sat, 14 Dec 2024 16:43:54 -0600 Subject: [PATCH] logic for complex pkgs, citra, pano, vdhcoapp --- flake.nix | 7 ++- pkgs/{citra.nix => citra/default.nix} | 2 +- pkgs/pano/default.nix | 51 +++++++++++++++++ pkgs/pano/pano_at_elhan.io.patch | 30 ++++++++++ pkgs/vdhcoapp/code.patch | 46 ++++++++++++++++ pkgs/vdhcoapp/default.nix | 79 +++++++++++++++++++++++++++ pkgs/vdhcoapp/filepicker.nix | 44 +++++++++++++++ 7 files changed, 257 insertions(+), 2 deletions(-) rename pkgs/{citra.nix => citra/default.nix} (93%) create mode 100644 pkgs/pano/default.nix create mode 100644 pkgs/pano/pano_at_elhan.io.patch create mode 100644 pkgs/vdhcoapp/code.patch create mode 100644 pkgs/vdhcoapp/default.nix create mode 100644 pkgs/vdhcoapp/filepicker.nix diff --git a/flake.nix b/flake.nix index a2311fc..bec1a7e 100644 --- a/flake.nix +++ b/flake.nix @@ -25,7 +25,12 @@ let scriptBin = path: name: pkgs.writeScriptBin name (builtins.readFile path); in - generatePackages { + { + citra = pkgs.callPackage ./pkgs/citra/default.nix { branch = "nightly"; }; + pano = pkgs.callPackage ./pkgs/pano/default.nix { }; + vdhcoapp = pkgs.callPackage ./pkgs/vdhcoapp/default.nix { }; + } + // generatePackages { dir = "pkgs"; ext = "nix"; handler = (path: name: pkgs.callPackage path { }); diff --git a/pkgs/citra.nix b/pkgs/citra/default.nix similarity index 93% rename from pkgs/citra.nix rename to pkgs/citra/default.nix index 98e8e05..cafc01c 100644 --- a/pkgs/citra.nix +++ b/pkgs/citra/default.nix @@ -15,7 +15,7 @@ let }; in { - nightly = qt6Packages.callPackage ./citra/generic.nix ( + nightly = qt6Packages.callPackage ./generic.nix ( let version = "2104"; in diff --git a/pkgs/pano/default.nix b/pkgs/pano/default.nix new file mode 100644 index 0000000..b0000ef --- /dev/null +++ b/pkgs/pano/default.nix @@ -0,0 +1,51 @@ +{ + stdenv, + gsound, + libgda6, + lib, + fetchzip, + substituteAll, + buildPackages, +}: + +stdenv.mkDerivation rec { + pname = "gnome-shell-extension-pano"; + version = "23-alpha3"; + src = fetchzip { + url = "https://github.com/oae/gnome-shell-pano/releases/download/v${version}/pano@elhan.io.zip"; + hash = "sha256-LYpxsl/PC8hwz0ZdH5cDdSZPRmkniBPUCqHQxB4KNhc="; + stripRoot = false; + }; + patches = [ + (substituteAll { + src = ./pano_at_elhan.io.patch; + inherit gsound libgda6; + }) + ]; + + nativeBuildInputs = [ buildPackages.glib ]; + + buildPhase = '' + runHook preBuild + if [ -d schemas ]; then + glib-compile-schemas --strict schemas + fi + runHook postBuild + ''; + installPhase = '' + runHook preInstall + mkdir -p $out/share/gnome-shell/extensions/ + cp -r -T . $out/share/gnome-shell/extensions/pano@elhan.io + runHook postInstall + ''; + meta = { + description = "Next-gen Clipboard manager for Gnome Shell"; + homepage = "https://github.com/oae/gnome-shell-pano"; + license = lib.licenses.gpl2Plus; + platforms = lib.platforms.linux; + }; + passthru = { + extensionPortalSlug = "pano"; + extensionUuid = "pano@elhan.io"; + }; +} diff --git a/pkgs/pano/pano_at_elhan.io.patch b/pkgs/pano/pano_at_elhan.io.patch new file mode 100644 index 0000000..3c47da1 --- /dev/null +++ b/pkgs/pano/pano_at_elhan.io.patch @@ -0,0 +1,30 @@ +diff --git a/__nix-prepend-search-paths.js b/__nix-prepend-search-paths.js +new file mode 100644 +index 0000000..bf3071b +--- /dev/null ++++ b/__nix-prepend-search-paths.js +@@ -0,0 +1,3 @@ ++import GIRepository from 'gi://GIRepository'; ++GIRepository.Repository.prepend_search_path('@gsound@/lib/girepository-1.0'); ++GIRepository.Repository.prepend_search_path('@libgda6@/lib/girepository-1.0'); +diff --git a/extension.js b/extension.js +index a3d6741..6a38850 100644 +--- a/extension.js ++++ b/extension.js +@@ -1,3 +1,4 @@ ++import './__nix-prepend-search-paths.js'; + import Gio from 'gi://Gio'; + import GLib from 'gi://GLib'; + import Shell from 'gi://Shell'; +diff --git a/prefs.js b/prefs.js +index 5dd94eb..634b2ef 100644 +--- a/prefs.js ++++ b/prefs.js +@@ -2,6 +2,7 @@ + import Gdk from 'gi://Gdk'; + import Gtk from 'gi://Gtk'; + import Adw from 'gi://Adw'; ++import './__nix-prepend-search-paths.js'; + import Gio from 'gi://Gio'; + import Pango from 'gi://Pango'; + import GObject from 'gi://GObject'; diff --git a/pkgs/vdhcoapp/code.patch b/pkgs/vdhcoapp/code.patch new file mode 100644 index 0000000..68e8ab7 --- /dev/null +++ b/pkgs/vdhcoapp/code.patch @@ -0,0 +1,46 @@ +diff --git a/src/converter.js b/src/converter.js +index af7b4c3..20da407 100644 +--- a/src/converter.js ++++ b/src/converter.js +@@ -1,4 +1,4 @@ +-import open from 'open'; ++function open() {} + + const os = require("os"); + const path = require('path'); +@@ -9,9 +9,9 @@ const rpc = require('./weh-rpc'); + + const exec_dir = path.dirname(process.execPath); + +-const ffmpeg = findExecutableFullPath("ffmpeg", exec_dir); +-const ffprobe = findExecutableFullPath("ffprobe", exec_dir); +-const filepicker = findExecutableFullPath("filepicker", exec_dir); ++const ffmpeg = "@ffmpeg@/bin/ffmpeg"; ++const ffprobe = "@ffmpeg@/bin/ffprobe"; ++const filepicker = "@filepicker@"; + + if (!fileExistsSync(ffmpeg)) { + logger.error("ffmpeg not found. Install ffmpeg and make sure it's in your path."); +diff --git a/src/main.js b/src/main.js +index 47b92de..e2e9402 100644 +--- a/src/main.js ++++ b/src/main.js +@@ -1,4 +1,4 @@ +-const config = require('config.json'); ++const config = require('./config.json'); + const converter = require('./converter'); + const os = require("os"); + +diff --git a/src/native-autoinstall.js b/src/native-autoinstall.js +index 556a22b..c729568 100644 +--- a/src/native-autoinstall.js ++++ b/src/native-autoinstall.js +@@ -1,7 +1,7 @@ + const os = require("os"); + const path = require("path"); + const { spawn, exec } = require('child_process'); +-const config = require('config.json'); ++const config = require('./config.json'); + + let fs; + if (process.versions.node.startsWith("10")) { diff --git a/pkgs/vdhcoapp/default.nix b/pkgs/vdhcoapp/default.nix new file mode 100644 index 0000000..003913b --- /dev/null +++ b/pkgs/vdhcoapp/default.nix @@ -0,0 +1,79 @@ +{ + lib, + fetchFromGitHub, + buildNpmPackage, + toml2json, + nodejs, + ffmpeg, + substituteAll, + makeWrapper, + callPackage, +}: + +# This is an adaptation with buildNpmPackage based on https://github.com/milahu/nur-packages/commit/3022ffb3619182ffcd579194e1202e3978e4d55b + +let + filepicker = callPackage ./filepicker.nix { }; +in +buildNpmPackage ( + let + version = "2.0.19"; + pname = "vdhcoapp"; + src = fetchFromGitHub { + owner = "aclap-dev"; + repo = "${pname}"; + rev = "v${version}"; + hash = "sha256-8xeZvqpRq71aShVogiwlVD3gQoPGseNOmz5E3KbsZxU="; + }; + in + { + inherit pname version src; + + sourceRoot = "${src.name}/app"; + npmDepsHash = "sha256-E032U2XZdyTER6ROkBosOTn7bweDXHl8voC3BQEz8Wg="; + dontNpmBuild = true; + + nativeBuildInputs = [ + toml2json + makeWrapper + ]; + + patches = [ + (substituteAll { + src = builtins.path { + path = ./code.patch; + name = "${src.name}-patch"; + }; + inherit ffmpeg; + filepicker = lib.getExe filepicker; + }) + ]; + + postPatch = '' + # Cannot use patch, setting placeholder here + substituteInPlace src/native-autoinstall.js \ + --replace process.execPath "\"${placeholder "out"}/bin/vdhcoapp\"" + ''; + + preBuild = '' + toml2json --pretty ../config.toml > src/config.json + ''; + + installPhase = '' + mkdir -p $out/opt/vdhcoapp + + cp -r . "$out/opt/vdhcoapp" + + makeWrapper ${nodejs}/bin/node $out/bin/vdhcoapp \ + --add-flags $out/opt/vdhcoapp/src/main.js + ''; + + meta = { + description = "Companion application for the Video DownloadHelper browser add-on"; + homepage = "https://www.downloadhelper.net/"; + license = lib.licenses.gpl2; + maintainers = [ lib.maintainers.wolfangaukang ]; + mainProgram = "vdhcoapp"; + }; + } +) diff --git a/pkgs/vdhcoapp/filepicker.nix b/pkgs/vdhcoapp/filepicker.nix new file mode 100644 index 0000000..49db62b --- /dev/null +++ b/pkgs/vdhcoapp/filepicker.nix @@ -0,0 +1,44 @@ +{ + lib, + rustPlatform, + fetchFromGitHub, + pkg-config, + atk, + gtk3, + glib, +}: + +rustPlatform.buildRustPackage ( + let + version = "1.0.1"; + in + { + pname = "filepicker"; + inherit version; + + src = fetchFromGitHub { + owner = "paulrouget"; + repo = "static-filepicker"; + rev = "v${version}"; + hash = "sha256-7sRzf3SA9RSBf4O36olXgka8c6Bufdb0qsuTofVe55s="; + }; + + cargoHash = "sha256-aal7ppFkCpNc+QTS4Qklsb9WfJ65QqG6p1eOskiX+/Q="; + + buildInputs = [ + atk + gtk3 + glib + ]; + + nativeBuildInputs = [ pkg-config ]; + + meta = { + description = "File picker used by VDHCoApp"; + homepage = "https://github.com/paulrouget/static-filepicker"; + license = lib.licenses.gpl2; + mainProgram = "filepicker"; + maintainers = [ lib.maintainers.hannesgith ]; + }; + } +)