diff --git a/pkgs/by-name/do/dorion/cargo-lock.patch b/pkgs/by-name/do/dorion/cargo-lock.patch new file mode 100644 index 0000000000000..8b970055ee4d6 --- /dev/null +++ b/pkgs/by-name/do/dorion/cargo-lock.patch @@ -0,0 +1,258 @@ +diff --git a/Cargo.lock b/Cargo.lock +index b86a7f5..861dad4 100644 +--- a/Cargo.lock ++++ b/Cargo.lock +@@ -2782,7 +2782,7 @@ version = "0.7.3" + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" + dependencies = [ +- "proc-macro-crate 1.3.1", ++ "proc-macro-crate 2.0.0", + "proc-macro2", + "quote", + "syn 2.0.79", +@@ -2795,7 +2795,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" + dependencies = [ + "malloc_buf", +- "objc_exception", + ] + + [[package]] +@@ -2814,6 +2813,9 @@ name = "objc-sys" + version = "0.3.5" + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" ++dependencies = [ ++ "cc", ++] + + [[package]] + name = "objc2" +@@ -2841,6 +2843,30 @@ dependencies = [ + "objc2-quartz-core", + ] + ++[[package]] ++name = "objc2-cloud-kit" ++version = "0.2.2" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" ++dependencies = [ ++ "bitflags 2.6.0", ++ "block2", ++ "objc2", ++ "objc2-core-location", ++ "objc2-foundation", ++] ++ ++[[package]] ++name = "objc2-contacts" ++version = "0.2.2" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "a5ff520e9c33812fd374d8deecef01d4a840e7b41862d849513de77e44aa4889" ++dependencies = [ ++ "block2", ++ "objc2", ++ "objc2-foundation", ++] ++ + [[package]] + name = "objc2-core-data" + version = "0.2.2" +@@ -2865,6 +2891,18 @@ dependencies = [ + "objc2-metal", + ] + ++[[package]] ++name = "objc2-core-location" ++version = "0.2.2" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "000cfee34e683244f284252ee206a27953279d370e309649dc3ee317b37e5781" ++dependencies = [ ++ "block2", ++ "objc2", ++ "objc2-contacts", ++ "objc2-foundation", ++] ++ + [[package]] + name = "objc2-encode" + version = "4.0.3" +@@ -2883,6 +2921,18 @@ dependencies = [ + "objc2", + ] + ++[[package]] ++name = "objc2-link-presentation" ++version = "0.2.2" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "a1a1ae721c5e35be65f01a03b6d2ac13a54cb4fa70d8a5da293d7b0020261398" ++dependencies = [ ++ "block2", ++ "objc2", ++ "objc2-app-kit", ++ "objc2-foundation", ++] ++ + [[package]] + name = "objc2-metal" + version = "0.2.2" +@@ -2909,25 +2959,71 @@ dependencies = [ + ] + + [[package]] +-name = "objc2-web-kit" ++name = "objc2-symbols" + version = "0.2.2" + source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "68bc69301064cebefc6c4c90ce9cba69225239e4b8ff99d445a2b5563797da65" ++checksum = "0a684efe3dec1b305badae1a28f6555f6ddd3bb2c2267896782858d5a78404dc" ++dependencies = [ ++ "objc2", ++ "objc2-foundation", ++] ++ ++[[package]] ++name = "objc2-ui-kit" ++version = "0.2.2" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" + dependencies = [ + "bitflags 2.6.0", + "block2", + "objc2", +- "objc2-app-kit", ++ "objc2-cloud-kit", ++ "objc2-core-data", ++ "objc2-core-image", ++ "objc2-core-location", + "objc2-foundation", ++ "objc2-link-presentation", ++ "objc2-quartz-core", ++ "objc2-symbols", ++ "objc2-uniform-type-identifiers", ++ "objc2-user-notifications", + ] + + [[package]] +-name = "objc_exception" +-version = "0.1.2" ++name = "objc2-uniform-type-identifiers" ++version = "0.2.2" + source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4" ++checksum = "44fa5f9748dbfe1ca6c0b79ad20725a11eca7c2218bceb4b005cb1be26273bfe" + dependencies = [ +- "cc", ++ "block2", ++ "objc2", ++ "objc2-foundation", ++] ++ ++[[package]] ++name = "objc2-user-notifications" ++version = "0.2.2" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" ++dependencies = [ ++ "bitflags 2.6.0", ++ "block2", ++ "objc2", ++ "objc2-core-location", ++ "objc2-foundation", ++] ++ ++[[package]] ++name = "objc2-web-kit" ++version = "0.2.2" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "68bc69301064cebefc6c4c90ce9cba69225239e4b8ff99d445a2b5563797da65" ++dependencies = [ ++ "bitflags 2.6.0", ++ "block2", ++ "objc2", ++ "objc2-app-kit", ++ "objc2-foundation", + ] + + [[package]] +@@ -4505,9 +4601,9 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" + + [[package]] + name = "tauri" +-version = "2.0.1" ++version = "2.0.5" + source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "f3fad474c02a3bcd4a304afff97159a31b9bab84e29563f7109c7b0ce8cd774e" ++checksum = "5ce2818e803ce3097987296623ed8c0d9f65ed93b4137ff9a83e168bdbf62932" + dependencies = [ + "anyhow", + "bytes", +@@ -4725,7 +4821,9 @@ dependencies = [ + + [[package]] + name = "tauri-plugin-shell" +-version = "2.0.1" ++version = "2.0.2" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "0ad7880c5586b6b2104be451e3d7fc0f3800c84bda69e9ba81c828f87cb34267" + dependencies = [ + "encoding_rs", + "log", +@@ -4774,9 +4872,9 @@ dependencies = [ + + [[package]] + name = "tauri-runtime" +-version = "2.0.1" ++version = "2.1.0" + source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "af12ad1af974b274ef1d32a94e6eba27a312b429ef28fcb98abc710df7f9151d" ++checksum = "c8f437293d6f5e5dce829250f4dbdce4e0b52905e297a6689cc2963eb53ac728" + dependencies = [ + "dpi", + "gtk", +@@ -4793,9 +4891,9 @@ dependencies = [ + + [[package]] + name = "tauri-runtime-wry" +-version = "2.0.1" ++version = "2.1.1" + source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "e45e88aa0b11b302d836e6ea3e507a6359044c4a8bc86b865ba99868c695753d" ++checksum = "1431602bcc71f2f840ad623915c9842ecc32999b867c4a787d975a17a9625cc6" + dependencies = [ + "gtk", + "http 1.1.0", +@@ -6187,14 +6285,12 @@ dependencies = [ + + [[package]] + name = "wry" +-version = "0.44.1" ++version = "0.46.3" + source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "440600584cfbd8b0d28eace95c1f2c253db05dae43780b79380aa1e868f04c73" ++checksum = "cd5cdf57c66813d97601181349c63b96994b3074fc3d7a31a8cce96e968e3bbd" + dependencies = [ + "base64 0.22.1", +- "block", +- "cocoa", +- "core-graphics", ++ "block2", + "crossbeam-channel", + "dpi", + "dunce", +@@ -6207,8 +6303,11 @@ dependencies = [ + "kuchikiki", + "libc", + "ndk", +- "objc", +- "objc_id", ++ "objc2", ++ "objc2-app-kit", ++ "objc2-foundation", ++ "objc2-ui-kit", ++ "objc2-web-kit", + "once_cell", + "percent-encoding", + "raw-window-handle", diff --git a/pkgs/by-name/do/dorion/cargo-toml.patch b/pkgs/by-name/do/dorion/cargo-toml.patch new file mode 100644 index 0000000000000..de705866be458 --- /dev/null +++ b/pkgs/by-name/do/dorion/cargo-toml.patch @@ -0,0 +1,18 @@ +diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml +index e18999b..442c847 100644 +--- a/src-tauri/Cargo.toml ++++ b/src-tauri/Cargo.toml +@@ -14,13 +14,6 @@ rust-version = "1.77.2" + strip = "debuginfo" + lto = true + +-# Patches +-[package.metadata.patch] +-crates = ["tauri-plugin-shell"] +- +-[patch.crates-io] +-tauri-plugin-shell = { path="./target/patch/tauri-plugin-shell-2.0.1" } +- + [build-dependencies] + tauri-build = { version = "2.0.0", features = [] } + diff --git a/pkgs/by-name/do/dorion/package.nix b/pkgs/by-name/do/dorion/package.nix index 859d509b25b67..f88ff5dac27e7 100644 --- a/pkgs/by-name/do/dorion/package.nix +++ b/pkgs/by-name/do/dorion/package.nix @@ -1,65 +1,168 @@ -{ lib -, stdenv -, fetchurl -, autoPatchelfHook -, dpkg -, glib-networking -, gst_all_1 -, libappindicator -, libayatana-appindicator -, webkitgtk_4_0 -, wrapGAppsHook3 +{ + lib, + stdenv, + fetchFromGitHub, + fetchurl, + rustPlatform, + wrapGAppsHook3, + glib-networking, + gst_all_1, + libayatana-appindicator, + nodejs, + openssl, + pkg-config, + yq-go, + pnpm, + webkitgtk_4_1, + copyDesktopItems, + cargo-tauri, + desktop-file-utils, }: +let + webkitgtk_4_1' = webkitgtk_4_1.override { + enableExperimental = true; + }; + + shelter = fetchurl { + url = "https://raw.githubusercontent.com/uwu/shelter-builds/c6fb071f74089639a7b2b6177144d31192cbf916/shelter.js"; + hash = "sha256-2zMvRITkgNnLJvKYtdMHwyXKaC8yIwjUezqYmsihz+o="; + meta = { + homepage = "https://github.com/uwu/shelter"; + sourceProvenance = [ lib.sourceTypes.binaryBytecode ]; # actually, minified JS + license = lib.licenses.cc0; + }; + }; +in + +# buildRustPackage doesn't respect cargoRoot +# ..so use stdenv.mkDerivation and rust hooks instead (see #350541) stdenv.mkDerivation (finalAttrs: { pname = "dorion"; - version = "5.0.1"; + version = "6.2.0"; - src = fetchurl { - url = "https://github.com/SpikeHD/Dorion/releases/download/v${finalAttrs.version }/Dorion_${finalAttrs.version}_amd64.deb"; - hash = "sha256-cCZikTZ+IU3mq/FkJfeggXLyWIsWG+a2qu1GbgW93WQ="; + src = fetchFromGitHub { + owner = "SpikeHD"; + repo = "Dorion"; + rev = "v${finalAttrs.version}"; + hash = "sha256-7isOL/853IMOUkepbu81INNFgjTHpo9dyvPaxMkBU1U="; }; - unpackCmd = '' - dpkg -X $curSrc . - ''; + cargoRoot = "src-tauri"; + buildAndTestSubdir = finalAttrs.cargoRoot; - runtimeDependencies = [ - glib-networking - libappindicator - libayatana-appindicator - ]; + cargoDeps = rustPlatform.fetchCargoVendor { + inherit (finalAttrs) pname version src; + sourceRoot = "${finalAttrs.src.name}/${finalAttrs.cargoRoot}"; + hash = "sha256-SX6OsGQK8Asj+vXiwK9W/wlYzP7DxRrPmi1EXWQsGQs="; + patches = [ + ./cargo-lock.patch + ]; + }; + + pnpmDeps = pnpm.fetchDeps { + inherit (finalAttrs) pname version src; + hash = "sha256-qrB+IpuAhoiKfwZvfF8RSZbiyASGIABmYUd70iqSPyw="; + }; nativeBuildInputs = [ - autoPatchelfHook - dpkg + pnpm.configHook + rustPlatform.cargoSetupHook + cargo-tauri.hook + rustPlatform.cargoCheckHook + nodejs + pkg-config wrapGAppsHook3 + yq-go + desktop-file-utils + copyDesktopItems ]; buildInputs = [ - glib-networking + openssl + webkitgtk_4_1 gst_all_1.gst-plugins-bad gst_all_1.gst-plugins-base gst_all_1.gst-plugins-good - webkitgtk_4_0 + glib-networking + libayatana-appindicator ]; - installPhase = '' - runHook preInstall + runtimeDependencies = [ + libayatana-appindicator + ]; + + patches = [ + ./cargo-toml.patch + ]; + + postPatch = '' + # apply cargo-lock patch (we have to do it from src-tauri subdir so cant use patches = [..]) + (cd /build/source/src-tauri && patch -p1 < ${./cargo-lock.patch}) + + # patch cargo-deps + (cd $cargoDepsCopy/tauri-plugin-shell-* && patch -p1 < /build/source/src-tauri/patches/tauri-plugin-shell+2.0.1.patch) + (cd $cargoDepsCopy/tauri-utils-* && patch -p3 <${./tauri-env-resource-dir.patch}) + substituteInPlace $cargoDepsCopy/libappindicator-sys-*/src/lib.rs \ + --replace "libayatana-appindicator3.so.1" "${libayatana-appindicator}/lib/libayatana-appindicator3.so.1" - mkdir -pv $out - mv -v {bin,lib,share} $out + # disable pre-build script and disable auto-updater + yq -iPo=json ' + .bundle.resources = (.bundle.resources | map(select(. != "updater*"))) + ' /build/source/src-tauri/tauri.conf.json - runHook postInstall + # copy shelter injection + cp ${shelter} /build/source/src-tauri/injection/shelter.js + + # Very hacky and 99% sure its not even right + mkdir -p /build/source/src-tauri/html + cp -r /build/source/src/* /build/source/src-tauri/html + ''; + + preBuild = '' + pnpm build:js ''; + postInstall = '' + mkdir -p $out/lib/dorion + cp -r /build/source/src-tauri/{injection,html} $out/lib/dorion + desktop-file-edit \ + --set-comment "Tiny alternative Discord client" \ + --set-key="Exec" --set-value="Dorion %U" \ + --set-key="TryExec" --set-value="Dorion" \ + --set-key="StartupWMClass" --set-value="Dorion" \ + --set-key="StartupNotify" --set-value="true" \ + --set-key="Categories" --set-value="Network;InstantMessaging;Chat;" \ + --set-key="Keywords" --set-value="dorion;discord;vencord;chat;im;vc;ds;dc;dsc;tauri;" \ + --set-key="Terminal" --set-value="false" \ + --set-key="MimeType" --set-value="x-scheme-handler/discord" \ + $out/share/applications/dorion.desktop + ''; + + env = { + TAURI_RESOURCE_DIR = "${placeholder "out"}/lib"; + }; + meta = { - homepage = "https://github.com/SpikeHD/Dorion"; + homepage = "https://spikehd.github.io/projects/dorion/"; description = "Tiny alternative Discord client"; + longDescription = '' + Dorion is an alternative Discord client aimed towards lower-spec or + storage-sensitive PCs that supports themes, plugins, and more! + ''; + changelog = "https://github.com/SpikeHD/Dorion/releases/tag/v${finalAttrs.version}"; + downloadPage = "https://github.com/SpikeHD/Dorion/releases/tag/v${finalAttrs.version}"; license = lib.licenses.gpl3Only; - mainProgram = "dorion"; - maintainers = with lib.maintainers; [ aleksana ]; - platforms = lib.intersectLists (lib.platforms.linux) (lib.platforms.x86_64); - sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + mainProgram = "Dorion"; + maintainers = with lib.maintainers; [ + nyabinary + aleksana + griffi-gh + ]; + platforms = lib.platforms.linux; + sourceProvenance = [ + lib.sourceTypes.binaryBytecode # actually, minified JS + lib.sourceTypes.fromSource + ]; }; }) diff --git a/pkgs/by-name/do/dorion/tauri-env-resource-dir.patch b/pkgs/by-name/do/dorion/tauri-env-resource-dir.patch new file mode 100644 index 0000000000000..9d34c83e7848f --- /dev/null +++ b/pkgs/by-name/do/dorion/tauri-env-resource-dir.patch @@ -0,0 +1,21 @@ +diff --git a/crates/tauri-utils/src/platform.rs b/crates/tauri-utils/src/platform.rs +index 162539c96..6e8e18be5 100644 +--- a/crates/tauri-utils/src/platform.rs ++++ b/crates/tauri-utils/src/platform.rs +@@ -264,7 +264,16 @@ fn is_cargo_output_directory(path: &std::path::Path) -> bool { + /// On iOS, it's `${exe_dir}/assets`. + /// + /// Android uses a special URI prefix that is resolved by the Tauri file system plugin `asset://localhost/` ++/// ++/// Additionally, the resource directory can be overriden by setting the `TAURI_RESOURCE_DIR` environment variable at compile time. + pub fn resource_dir(package_info: &PackageInfo, env: &Env) -> crate::Result { ++ if let Some(dir) = option_env!("TAURI_RESOURCE_DIR") { ++ return Ok(PathBuf::from(format!( ++ "{}/{}", ++ dir, ++ package_info.name ++ ))); ++ } + #[cfg(target_os = "android")] + return resource_dir_android(package_info, env); + #[cfg(not(target_os = "android"))] \ No newline at end of file