diff --git a/pkgs/by-name/do/dorion/package.nix b/pkgs/by-name/do/dorion/package.nix index 859d509b25b67b..db5fcec2bd92b7 100644 --- a/pkgs/by-name/do/dorion/package.nix +++ b/pkgs/by-name/do/dorion/package.nix @@ -1,65 +1,186 @@ -{ lib -, stdenv -, fetchurl -, autoPatchelfHook -, dpkg -, glib-networking -, gst_all_1 -, libappindicator -, libayatana-appindicator -, webkitgtk_4_0 -, wrapGAppsHook3 +{ + lib, + stdenv, + fetchFromGitHub, + fetchurl, + rustPlatform, + autoPatchelfHook, + wrapGAppsHook3, + glib-networking, + gst_all_1, + libappindicator, + libayatana-appindicator, + nodejs, + openssl, + pkg-config, + yq-go, + pnpm, + webkitgtk_4_1, + makeDesktopItem, + copyDesktopItems, }: -stdenv.mkDerivation (finalAttrs: { +let 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="; + webkitgtk_4_1' = webkitgtk_4_1.override { enableExperimental = true; }; + + src = fetchFromGitHub { + owner = "SpikeHD"; + repo = "Dorion"; + rev = "v${version}"; + hash = "sha256-7isOL/853IMOUkepbu81INNFgjTHpo9dyvPaxMkBU1U="; + + nativeBuildInputs = [ pnpm.configHook ]; }; - unpackCmd = '' - dpkg -X $curSrc . - ''; + 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; + }; + }; - runtimeDependencies = [ - glib-networking - libappindicator - libayatana-appindicator - ]; + frontend = stdenv.mkDerivation { + pname = "dorion-ui"; + inherit version src; + + pnpmDeps = pnpm.fetchDeps { + inherit pname version src; + hash = "sha256-qrB+IpuAhoiKfwZvfF8RSZbiyASGIABmYUd70iqSPyw="; + }; + + nativeBuildInputs = [ + pnpm.configHook + nodejs + copyDesktopItems + ]; + + buildPhase = '' + runHook preBuild + + cp ${shelter} src-tauri/injection/shelter.js + pnpm build + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out + cp -r src-tauri/{injection,html} $out + + runHook postInstall + ''; + }; + +in + +rustPlatform.buildRustPackage { + inherit pname version src; + + sourceRoot = "${src.name}/src-tauri"; + + useFetchCargoVendor = true; + cargoHash = "sha256-dXWw/lro8JHZsLeYO8DvqJaH8JNQh7zQ0vKjEpG8fOE="; nativeBuildInputs = [ + pkg-config + yq-go autoPatchelfHook - dpkg wrapGAppsHook3 ]; 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 ]; - installPhase = '' - runHook preInstall + runtimeDependencies = [ + libappindicator + libayatana-appindicator + ]; - mkdir -pv $out - mv -v {bin,lib,share} $out + env = { + TAURI_RESOURCE_DIR = "${placeholder "out"}/lib"; + }; - runHook postInstall + postPatch = '' + # disable pre-build script, change distribution dir from an URL to src, and disable auto-updater + yq -iPo=json ' + .build.beforeBuildCommand = "" | + .build.frontendDist = "src" | + .bundle.resources = (.bundle.resources | map(select(. != "updater*"))) + ' tauri.conf.json + + (cd $cargoDepsCopy/tauri-utils-* && patch -p3 <${./tauri-env-resource-dir.patch}) + ''; + + preConfigure = '' + cp -r ${frontend}/* ./ + ''; + + postInstall = '' + mkdir -p $out/lib/dorion + cp -r {injection,html} $out/lib/dorion + install -Dm644 "$out/share/icons/hicolor/32x32/apps/dorion.png" "./${src.name}/src-tauri/icons/32x32icon.png" + install -Dm644 "$out/share/icons/hicolor/128x128/apps/dorion.png" "./${src.name}/src-tauri/icons/128x128.png" + install -Dm644 "$out/share/icons/hicolor/256x256/apps/dorion.png" "./${src.name}/src-tauri/icons/128x128@2.png" + install -Dm644 "$out/share/icons/hicolor/512x512/apps/dorion.png" "./${src.name}/src-tauri/icons/icon.png" ''; + desktopItems = [ + (makeDesktopItem { + name = "dorion"; + genericName = "Internet Messenger"; + desktopName = "Dorion"; + exec = "dorion %U"; + tryExec = "dorion %U"; + icon = "dorion"; + comment = "Tiny alternative Discord client"; + keywords = [ + "discord" + "vencord" + "tauri" + "chat" + ]; + categories = [ + "Network" + "InstantMessaging" + "Chat" + ]; + mimeTypes = [ "x-scheme-handler/discord" ]; + startupWMClass = "Dorion"; + terminal = false; + }) + ]; + + passthru = { + inherit frontend; + }; + meta = { homepage = "https://github.com/SpikeHD/Dorion"; description = "Tiny alternative Discord client"; 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 ]; + maintainers = with lib.maintainers; [ + nyabinary + aleksana + ]; + 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