diff --git a/pkgs/by-name/do/dorion/no-cargo-patch.patch b/pkgs/by-name/do/dorion/no-cargo-patch.patch new file mode 100644 index 00000000000000..d39f967eefe318 --- /dev/null +++ b/pkgs/by-name/do/dorion/no-cargo-patch.patch @@ -0,0 +1,31 @@ +diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock +index 59f676d..b7090d4 100644 +--- a/src-tauri/Cargo.lock ++++ b/src-tauri/Cargo.lock +@@ -4954,6 +4954,8 @@ dependencies = [ + [[package]] + name = "tauri-plugin-shell" + version = "2.0.2" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "0ad7880c5586b6b2104be451e3d7fc0f3800c84bda69e9ba81c828f87cb34267" + dependencies = [ + "encoding_rs", + "log", +diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml +index 62a508b..0bbe935 100644 +--- a/src-tauri/Cargo.toml ++++ b/src-tauri/Cargo.toml +@@ -12,13 +12,6 @@ rust-version = "1.81" + 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.2" } +- + [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 859d509b25b67b..d161cda7e94bb9 100644 --- a/pkgs/by-name/do/dorion/package.nix +++ b/pkgs/by-name/do/dorion/package.nix @@ -1,65 +1,195 @@ -{ lib -, stdenv -, fetchurl -, autoPatchelfHook -, dpkg -, glib-networking -, gst_all_1 -, libappindicator -, libayatana-appindicator -, webkitgtk_4_0 -, wrapGAppsHook3 +{ + lib, + fetchFromGitHub, + fetchurl, + rustPlatform, + cmake, + ninja, + wrapGAppsHook4, + glib-networking, + gst_all_1, + libsysprof-capture, + libayatana-appindicator, + nodejs, + openssl, + pkg-config, + yq-go, + pnpm_9, + webkitgtk_4_1, + cargo-tauri, + desktop-file-utils, }: -stdenv.mkDerivation (finalAttrs: { +let + webkitgtk_4_1' = webkitgtk_4_1.override { + enableExperimental = true; + }; + + shelter = fetchurl { + url = "https://raw.githubusercontent.com/uwu/shelter-builds/de7151650c240fc226d41ff898547edc4d23c94d/shelter.js"; + hash = "sha256-dqAbq4O61t91gnVBOiN5KgJG3Frg9ePMPKjn9QWtkws="; + meta = { + homepage = "https://github.com/uwu/shelter"; + sourceProvenance = [ lib.sourceTypes.binaryBytecode ]; # actually, minified JS + license = lib.licenses.cc0; + }; + }; +in + +# nyo finalAttrs :< +# https://github.com/NixOS/nixpkgs/pull/194475 +rustPlatform.buildRustPackage rec { pname = "dorion"; - version = "5.0.1"; + version = "6.4.1"; - 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${version}"; + hash = "sha256-La58qj9acZzTG7WDfnBNdVWzAjOYVkIZzO8uyjQvt6o="; }; - unpackCmd = '' - dpkg -X $curSrc . - ''; + cargoPatches = [ + ./no-cargo-patch.patch + ]; - runtimeDependencies = [ - glib-networking - libappindicator - libayatana-appindicator + cargoRoot = "src-tauri"; + buildAndTestSubdir = cargoRoot; + + useFetchCargoVendor = true; + cargoHash = "sha256-5qK1IRaUrf4pYDmoBZoR6q6rL06irurwo4v5JLX+Io4="; + + pnpmDeps = pnpm_9.fetchDeps { + inherit pname version src; + hash = "sha256-xBonUzA4+1zbViEsKap6CaG6ZRldW1LjNYIB+FmVRFs="; + }; + + # CMake (webkit extension) + cmakeDir = "."; + cmakeBuildDir = "src-tauri/extension_webkit"; + dontUseCmakeConfigure = true; + dontUseNinjaBuild = true; + dontUseNinjaCheck = true; + dontUseNinjaInstall = true; + # cmake's supposed to set this automatically + # ... but the detection is based on the presence of ninja build hook + cmakeFlags = [ + "-GNinja" ]; nativeBuildInputs = [ - autoPatchelfHook - dpkg - wrapGAppsHook3 + pnpm_9.configHook + cargo-tauri.hook + nodejs + pkg-config + wrapGAppsHook4 + yq-go + desktop-file-utils + cmake + ninja ]; 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 + libsysprof-capture + libayatana-appindicator ]; - installPhase = '' - runHook preInstall + postPatch = '' + # remove updater + rm -rf updater - mkdir -pv $out - mv -v {bin,lib,share} $out + # patch cargo-deps + pushd $cargoDepsCopy/tauri-plugin-shell-* + patch -p1 < /build/source/src-tauri/patches/tauri-plugin-shell+*.patch + popd - runHook postInstall + pushd $cargoDepsCopy/tauri-utils-* + patch -p3 <${./tauri-env-resource-dir.patch} + popd + + substituteInPlace $cargoDepsCopy/libappindicator-sys-*/src/lib.rs \ + --replace "libayatana-appindicator3.so.1" "${libayatana-appindicator}/lib/libayatana-appindicator3.so.1" + + # disable pre-build script and disable auto-updater + yq -iPo=json ' + .bundle.resources = (.bundle.resources | map(select(. != "updater*"))) + ' src-tauri/tauri.conf.json + + # link shelter injection + ln -s ${shelter} src-tauri/injection/shelter.js + + # link html/frontend data + ln -s src src-tauri/html + ''; + + configurePhase = '' + cmakeConfigurePhase + pnpmConfigHook + ''; + + buildPhase = '' + ninjaBuildPhase + cd /build/source + tauriBuildHook + ''; + + postInstall = '' + # Set up the resource directories + mkdir -p $out/lib/Dorion + ln -s $out/lib/Dorion $out/lib/dorion + rm -rf $out/lib/Dorion/injection + cp -r src-tauri/injection $out/lib/Dorion + cp -rL src-tauri/html $out/lib/Dorion + + # Modify the desktop file + 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 ''; + # error: failed to run custom build command for `Dorion v6.4.1 (/build/source/src-tauri)` + # Permission denied (os error 13) + doCheck = false; + + 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${version}"; + downloadPage = "https://github.com/SpikeHD/Dorion/releases/tag/v${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 + getchoo + ]; + 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 00000000000000..9d34c83e7848fa --- /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