-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0402340
commit 185cc45
Showing
2 changed files
with
111 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,122 @@ | ||
{ | ||
appimageTools, | ||
lib, | ||
fetchurl, | ||
cargo-tauri, | ||
cargo-tauri_1, | ||
fetchFromGitHub, | ||
glib-networking, | ||
libayatana-appindicator, | ||
libsoup_2_4, | ||
libsoup_3, | ||
nix-update, | ||
nodejs, | ||
openssl, | ||
perl, | ||
pkg-config, | ||
pnpm, | ||
protobuf, | ||
rustPlatform, | ||
stdenv, | ||
webkitgtk_4_0, | ||
webkitgtk_4_1, | ||
wrapGAppsHook4, | ||
writeShellScript, | ||
|
||
# This package provides can be built using tauri v1 or v2. | ||
# Try legacy (v1) version if main (v2) doesn't work. | ||
app-type ? "main", # main or legacy | ||
}: | ||
let | ||
pname = "rquickshare"; | ||
version = "0.11.2"; | ||
src = fetchurl { | ||
url = "https://github.com/Martichou/rquickshare/releases/download/v${version}/r-quick-share-legacy_v${version}_glibc-2.31_amd64.AppImage"; | ||
hash = "sha256-VXYiYrTSedH8xFjuxbdplzVdfnO6s3ftY2I121Unlfw="; | ||
}; | ||
appimageContents = appimageTools.extractType2 { inherit pname version src; }; | ||
app-type-either = | ||
arg1: arg2: | ||
if app-type == "main" then | ||
arg1 | ||
else if app-type == "legacy" then | ||
arg2 | ||
else | ||
throw "Wrong argument for app-type in rquickshare package"; | ||
|
||
proper-cargo-tauri = app-type-either cargo-tauri cargo-tauri_1; | ||
in | ||
appimageTools.wrapType2 { | ||
inherit pname version src; | ||
extraInstallCommands = '' | ||
install -Dm444 ${appimageContents}/r-quick-share.desktop -t $out/share/applications | ||
substituteInPlace $out/share/applications/r-quick-share.desktop \ | ||
--replace-fail 'Exec=r-quick-share' 'Exec=r-quick-share %u' | ||
cp -r ${appimageContents}/usr/share/icons $out/share | ||
rustPlatform.buildRustPackage rec { | ||
pname = "rquickshare" + (app-type-either "" "-legacy"); | ||
version = "0.11.3"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "Martichou"; | ||
repo = "rquickshare"; | ||
tag = "v${version}"; | ||
hash = "sha256-6gXt1UGcjOFInsCep56s3K5Zk/KIz2ZrFlmrgXP7/e8="; | ||
}; | ||
|
||
# from https://github.com/NixOS/nixpkgs/blob/04e40bca2a68d7ca85f1c47f00598abb062a8b12/pkgs/by-name/ca/cargo-tauri/test-app.nix#L23-L26 | ||
postPatch = lib.optionalString stdenv.hostPlatform.isLinux '' | ||
substituteInPlace $cargoDepsCopy/libappindicator-sys-*/src/lib.rs \ | ||
--replace-fail "libayatana-appindicator3.so.1" "${libayatana-appindicator}/lib/libayatana-appindicator3.so.1" | ||
''; | ||
|
||
pnpmRoot = "app/${app-type}"; | ||
pnpmDeps = pnpm.fetchDeps { | ||
inherit pname version src; | ||
|
||
sourceRoot = "${src.name}/app/${app-type}"; | ||
hash = app-type-either "sha256-V46V/VPwCKEe3sAp8zK0UUU5YigqgYh1GIOorqIAiNE=" "sha256-sDHysaKMdNcbL1szww7/wg0bGHOnEKsKoySZJJCcPik="; | ||
}; | ||
|
||
useFetchCargoVendor = true; | ||
cargoRoot = "app/${app-type}/src-tauri"; | ||
buildAndTestSubdir = cargoRoot; | ||
cargoHash = app-type-either "sha256-KOiu0D8LpPUilxWZ3XKSGDh1fCT66Y0G6MyyJN8rH4Q=" "sha256-PgzrteOa382L//DTZKeDHx1AUt/mG/CxV3WXXIj3ENo="; | ||
|
||
nativeBuildInputs = [ | ||
proper-cargo-tauri.hook | ||
|
||
# Setup pnpm | ||
nodejs | ||
pnpm.configHook | ||
|
||
# Make sure we can find our libraries | ||
perl | ||
pkg-config | ||
protobuf | ||
wrapGAppsHook4 | ||
]; | ||
|
||
buildInputs = | ||
[ openssl ] | ||
++ lib.optionals stdenv.hostPlatform.isLinux [ | ||
glib-networking # Most Tauri apps need networking | ||
libayatana-appindicator | ||
] | ||
++ lib.optionals (app-type == "main") [ | ||
webkitgtk_4_1 | ||
libsoup_3 | ||
] | ||
++ lib.optionals (app-type == "legacy") [ | ||
webkitgtk_4_0 | ||
libsoup_2_4 | ||
]; | ||
|
||
passthru.updateScript = | ||
let | ||
updateScript = writeShellScript "update-rquickshare.sh" '' | ||
${lib.getExe nix-update} rquickshare | ||
sed -i 's/version = "0.0.0";/' pkgs/by-name/rq/rquickshare/package.nix | ||
${lib.getExe nix-update} rquickshare-legacy | ||
''; | ||
in | ||
# Don't set an update script for the legacy version | ||
# so r-ryantm won't create two duplicate PRs | ||
app-type-either updateScript null; | ||
|
||
meta = { | ||
description = "Rust implementation of NearbyShare/QuickShare from Android for Linux"; | ||
description = "Rust implementation of NearbyShare/QuickShare from Android for Linux and macOS"; | ||
homepage = "https://github.com/Martichou/rquickshare"; | ||
changelog = "https://github.com/Martichou/rquickshare/blob/v${version}/CHANGELOG.md"; | ||
license = lib.licenses.gpl3Plus; | ||
maintainers = [ lib.maintainers.luftmensch-luftmensch ]; | ||
platforms = [ "x86_64-linux" ]; | ||
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; | ||
mainProgram = "rquickshare"; | ||
mainProgram = app-type-either "rquickshare" "r-quick-share"; | ||
maintainers = with lib.maintainers; [ | ||
perchun | ||
luftmensch-luftmensch | ||
]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters