Skip to content

Commit

Permalink
dorion: 5.0.1 -> 5.2.0; dorion: build from source
Browse files Browse the repository at this point in the history
  • Loading branch information
nyabinary committed Nov 17, 2024
1 parent cd43d68 commit 053b2e3
Show file tree
Hide file tree
Showing 2 changed files with 178 additions and 36 deletions.
193 changes: 157 additions & 36 deletions pkgs/by-name/do/dorion/package.nix
Original file line number Diff line number Diff line change
@@ -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/[email protected]"
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
];
};
})
}
21 changes: 21 additions & 0 deletions pkgs/by-name/do/dorion/tauri-env-resource-dir.patch
Original file line number Diff line number Diff line change
@@ -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<PathBuf> {
+ 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"))]

0 comments on commit 053b2e3

Please sign in to comment.