cargo-tauri.hook: init (#335751)

This commit is contained in:
Philip Taron
2024-09-30 17:17:38 -07:00
committed by GitHub
19 changed files with 1809 additions and 263 deletions
+1
View File
@@ -30,6 +30,7 @@ postgresql-test-hook.section.md
premake.section.md
python.section.md
scons.section.md
tauri.section.md
tetex-tex-live.section.md
unzip.section.md
validatePkgConfig.section.md
+108
View File
@@ -0,0 +1,108 @@
# cargo-tauri.hook {#tauri-hook}
[Tauri](https://tauri.app/) is a framework for building smaller, faster, and
more secure desktop applications with a web frontend.
In Nixpkgs, `cargo-tauri.hook` overrides the default build and install phases.
## Example code snippet {#tauri-hook-example-code-snippet}
```nix
{
lib,
stdenv,
rustPlatform,
fetchNpmDeps,
cargo-tauri,
darwin,
glib-networking,
libsoup,
nodejs,
npmHooks,
openssl,
pkg-config,
webkitgtk,
wrapGAppsHook3,
}:
rustPlatform.buildRustPackage rec {
# . . .
cargoHash = "...";
# Assuming our app's frontend uses `npm` as a package manager
npmDeps = fetchNpmDeps {
name = "${pname}-npm-deps-${version}";
inherit src;
hash = "...";
};
nativeBuildInputs = [
# Pull in our main hook
cargo-tauri.hook
# Setup npm
nodejs
npmHooks.npmConfigHook
# Make sure we can find our libraries
pkg-config
wrapGAppsHook3
];
buildInputs =
[ openssl ]
++ lib.optionals stdenv.isLinux [
glib-networking # Most Tauri apps need networking
libsoup
webkitgtk
]
++ lib.optionals stdenv.isDarwin (
with darwin.apple_sdk.frameworks;
[
AppKit
CoreServices
Security
WebKit
]
);
# Set our Tauri source directory
cargoRoot = "src-tauri";
# And make sure we build there too
buildAndTestSubdir = cargoRoot;
# . . .
}
```
## Variables controlling cargo-tauri {#tauri-hook-variables-controlling}
### Tauri Exclusive Variables {#tauri-hook-exclusive-variables}
#### `tauriBuildFlags` {#tauri-build-flags}
Controls the flags passed to `cargo tauri build`.
#### `tauriBundleType` {#tauri-bundle-type}
The [bundle type](https://tauri.app/v1/guides/building/) to build.
#### `dontTauriBuild` {#dont-tauri-build}
Disables using `tauriBuildHook`.
#### `dontTauriInstall` {#dont-tauri-install}
Disables using `tauriInstallPostBuildHook` and `tauriInstallHook`.
### Honored Variables {#tauri-hook-honored-variables}
Along with those found in [](#compiling-rust-applications-with-cargo), the
following variables used by `cargoBuildHook` and `cargoInstallHook` are honored
by the cargo-tauri setup hook.
- `buildAndTestSubdir`
- `cargoBuildType`
- `cargoBuildNoDefaultFeatures`
- `cargoBuildFeatures`
@@ -591,6 +591,9 @@
- The arguments from [](#opt-services.postgresql.initdbArgs) now get shell-escaped.
- `cargo-tauri.hook` was introduced to help users build [Tauri](https://tauri.app/) projects. It is meant to be used alongside
`rustPlatform.buildRustPackage` and Node hooks such as `npmConfigHook`, `pnpm.configHook`, and the new `yarnConfig`
- Support for *runner registration tokens* has been [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/380872)
in `gitlab-runner` 15.6 and is expected to be removed in `gitlab-runner` 18.0. Configuration of existing runners
should be changed to using *runner authentication tokens* by configuring
+13 -22
View File
@@ -1,5 +1,4 @@
{ lib
, cmake
, dbus
, fetchFromGitHub
, fetchYarnDeps
@@ -13,12 +12,14 @@
, cyrus_sasl
, stdenv
, fixup_yarn_lock
, yarn
, yarnConfigHook
, nodejs-slim
, cargo-tauri
, cargo
, rustPlatform
, rustc
, jq
, moreutils
}:
stdenv.mkDerivation rec {
@@ -32,6 +33,11 @@ stdenv.mkDerivation rec {
hash = "sha256-Bi9GCQr7yox5Plc7o0svRKYi1XoK/HDGj1VbW1z4jac=";
};
# Yarn *really* wants us to use corepack if this is set
postPatch = ''
jq 'del(.packageManager)' package.json | sponge package.json
'';
yarnOfflineCache = fetchYarnDeps {
yarnLock = "${src}/yarn.lock";
hash = "sha256-ih5NSOvYje981SkVfPHm/u2sS1B36kgxpfe9LmQaxdo=";
@@ -47,37 +53,22 @@ stdenv.mkDerivation rec {
};
};
configurePhase = ''
export HOME=$(mktemp -d)
yarn config --offline set yarn-offline-mirror ${yarnOfflineCache}
fixup_yarn_lock yarn.lock
yarn install --offline --frozen-lockfile --ignore-scripts --no-progress --non-interactive
patchShebangs node_modules/
yarn run postinstall --offline
'';
preBuild = ''
yarn tauri build -b deb
'';
cargoRoot = "backend/";
preInstall = ''
mv backend/target/release/bundle/deb/*/data/usr/ "$out"
'';
buildAndTestDir = cargoRoot;
nativeBuildInputs = [
cmake
pkg-config
perl
rustPlatform.cargoSetupHook
cargo
rustc
cargo-tauri
cargo-tauri.hook
fixup_yarn_lock
yarn
yarnConfigHook
nodejs-slim
cyrus_sasl
jq
moreutils # for sponge
];
buildInputs = [
+56
View File
@@ -0,0 +1,56 @@
{
lib,
stdenv,
makeSetupHook,
cargo,
cargo-tauri,
rust,
# The subdirectory of `target/` from which to copy the build artifacts
targetSubdirectory ? stdenv.hostPlatform.rust.cargoShortTarget,
}:
let
kernelName = stdenv.hostPlatform.parsed.kernel.name;
in
makeSetupHook {
name = "tauri-hook";
propagatedBuildInputs = [
cargo
cargo-tauri
];
substitutions = {
inherit targetSubdirectory;
inherit (rust.envVars) rustHostPlatformSpec setEnv;
# A map of the bundles used for Tauri's different supported platforms
# https://github.com/tauri-apps/tauri/blob/23a912bb84d7c6088301e1ffc59adfa8a799beab/README.md#platforms
defaultTauriBundleType =
{
darwin = "app";
linux = "deb";
}
.${kernelName} or (throw "${kernelName} is not supported by cargo-tauri.hook");
# $targetDir is the path to the build artifacts (i.e., `./target/release`)
installScript =
{
darwin = ''
mkdir $out
mv "$targetDir"/bundle/macos $out/Applications
'';
linux = ''
mv "$targetDir"/bundle/deb/*/data/usr $out
'';
}
.${kernelName} or (throw "${kernelName} is not supported by cargo-tauri.hook");
};
meta = {
inherit (cargo-tauri.meta) maintainers broken;
# Platforms that Tauri supports bundles for
platforms = lib.platforms.darwin ++ lib.platforms.linux;
};
} ./hook.sh
+101
View File
@@ -0,0 +1,101 @@
# shellcheck shell=bash disable=SC2034,SC2154,SC2164
# We replace these
export dontCargoBuild=true
export dontCargoInstall=true
tauriBuildHook() {
echo "Executing tauriBuildHook"
runHook preBuild
## The following is lifted from rustPlatform.cargoBuildHook
## As we're replacing it, we should also be respecting its options.
# Account for running outside of mkRustPackage where this may not be set
cargoBuildType="${cargoBuildType:-release}"
# Let stdenv handle stripping, for consistency and to not break
# separateDebugInfo.
export "CARGO_PROFILE_${cargoBuildType@U}_STRIP"=false
if [ -n "${buildAndTestSubdir-}" ]; then
# ensure the output doesn't end up in the subdirectory
CARGO_TARGET_DIR="$(pwd)/target"
export CARGO_TARGET_DIR
# Tauri doesn't respect $CARGO_TARGET_DIR, but does respect the cargo
# argument...but that doesn't respect `--target`, so we have to use the
# config file
# https://github.com/tauri-apps/tauri/issues/10190
printf '\nbuild.target-dir = "%s"' "$CARGO_TARGET_DIR" >>config.toml
pushd "${buildAndTestSubdir}"
fi
local cargoFlagsArray=(
"-j" "$NIX_BUILD_CORES"
"--target" "@rustHostPlatformSpec@"
"--offline"
)
local tauriFlagsArray=(
"--bundles" "${tauriBundleType:-@defaultTauriBundleType@}"
"--target" "@rustHostPlatformSpec@"
)
if [ "${cargoBuildType}" != "debug" ]; then
cargoFlagsArray+=("--profile" "${cargoBuildType}")
fi
if [ -n "${cargoBuildNoDefaultFeatures-}" ]; then
cargoFlagsArray+=("--no-default-features")
fi
if [ -n "${cargoBuildFeatures-}" ]; then
cargoFlagsArray+=("--features=$(concatStringsSep "," cargoBuildFeatures)")
fi
concatTo cargoFlagsArray cargoBuildFlags
if [ "${cargoBuildType:-}" == "debug" ]; then
tauriFlagsArray+=("--debug")
fi
concatTo tauriFlagsArray tauriBuildFlags
echoCmd 'cargo-tauri.hook cargoFlags' "${cargoFlagsArray[@]}"
echoCmd 'cargo-tauri.hook tauriFlags' "${tauriFlagsArray[@]}"
@setEnv@ cargo tauri build "${tauriFlagsArray[@]}" -- "${cargoFlagsArray[@]}"
if [ -n "${buildAndTestSubdir-}" ]; then
popd
fi
runHook postBuild
echo "Finished tauriBuildHook"
}
tauriInstallHook() {
echo "Executing tauriInstallHook"
runHook preInstall
# Use a nice variable for our target directory in the following script
targetDir=target/@targetSubdirectory@/$cargoBuildType
@installScript@
runHook postInstall
echo "Finished tauriInstallHook"
}
if [ -z "${dontTauriBuild:-}" ] && [ -z "${buildPhase:-}" ]; then
buildPhase=tauriBuildHook
fi
if [ -z "${dontTauriInstall:-}" ] && [ -z "${installPhase:-}" ]; then
installPhase=tauriInstallHook
fi
@@ -1,21 +1,17 @@
{
lib,
stdenv,
callPackage,
rustPlatform,
fetchFromGitHub,
darwin,
gtk3,
libsoup,
openssl,
pkg-config,
glibc,
libsoup,
cairo,
gtk3,
webkitgtk,
darwin,
}:
let
inherit (darwin.apple_sdk.frameworks) CoreServices Security SystemConfiguration;
in
rustPlatform.buildRustPackage rec {
pname = "tauri";
version = "1.7.1-unstable-2024-08-16";
@@ -33,33 +29,46 @@ rustPlatform.buildRustPackage rec {
cargoHash = "sha256-VXg/dAhwPTSrLwJm8HNzAi/sVF9RqgpHIF3PZe1LjSA=";
nativeBuildInputs = [ pkg-config ];
buildInputs =
[ openssl ]
++ lib.optionals stdenv.hostPlatform.isLinux [
glibc
libsoup
cairo
gtk3
libsoup
webkitgtk
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
CoreServices
Security
SystemConfiguration
];
nativeBuildInputs = [ pkg-config ];
++ lib.optionals stdenv.hostPlatform.isDarwin (
with darwin.apple_sdk.frameworks;
[
CoreServices
Security
SystemConfiguration
]
);
passthru = {
# See ./doc/hooks/tauri.section.md
hook = callPackage ./hook.nix { };
tests = {
setupHooks = callPackage ./test-app.nix { };
};
};
meta = {
description = "Build smaller, faster, and more secure desktop applications with a web frontend";
mainProgram = "cargo-tauri";
homepage = "https://tauri.app/";
changelog = "https://github.com/tauri-apps/tauri/releases/tag/tauri-v${version}";
license = with lib.licenses; [
asl20 # or
mit
];
maintainers = with lib.maintainers; [
dit7ya
getchoo
happysalada
];
mainProgram = "cargo-tauri";
};
}
+60
View File
@@ -0,0 +1,60 @@
{
lib,
stdenv,
rustPlatform,
cargo-tauri,
darwin,
glib-networking,
libsoup,
openssl,
pkg-config,
webkitgtk,
wrapGAppsHook3,
}:
rustPlatform.buildRustPackage rec {
pname = "test-app";
inherit (cargo-tauri) version src;
# Basic example provided by upstream
sourceRoot = "${src.name}/examples/workspace";
cargoPatches = [
# https://github.com/NixOS/nixpkgs/issues/332957
./update-time-crate.patch
];
cargoHash = "sha256-ull9BWzeKsnMi4wcH67FnKFzTjqEdiRlM3f+EKIPvvU=";
nativeBuildInputs = [
cargo-tauri.hook
pkg-config
wrapGAppsHook3
];
buildInputs =
[ openssl ]
++ lib.optionals stdenv.isLinux [
glib-networking
libsoup
webkitgtk
]
++ lib.optionals stdenv.isDarwin (
with darwin.apple_sdk.frameworks;
[
AppKit
CoreServices
Security
WebKit
]
);
# No one should be actually running this, so lets save some time
buildType = "debug";
doCheck = false;
meta = {
inherit (cargo-tauri.hook.meta) platforms;
};
}
File diff suppressed because it is too large Load Diff
+10 -31
View File
@@ -3,11 +3,10 @@
stdenv,
darwin,
fetchFromGitHub,
rust,
rustPlatform,
cargo-tauri,
cinny,
copyDesktopItems,
desktop-file-utils,
wrapGAppsHook3,
pkg-config,
openssl,
@@ -16,7 +15,6 @@
glib-networking,
libayatana-appindicator,
webkitgtk,
makeDesktopItem,
}:
rustPlatform.buildRustPackage rec {
@@ -58,27 +56,22 @@ rustPlatform.buildRustPackage rec {
--replace "libayatana-appindicator3.so.1" "${libayatana-appindicator}/lib/libayatana-appindicator3.so.1"
'';
postBuild = lib.optionalString stdenv.hostPlatform.isDarwin ''
cargo tauri build --bundles app --target "${rust.envVars.rustHostPlatform}"
'';
postInstall =
lib.optionalString stdenv.hostPlatform.isLinux ''
install -DT icons/128x128@2x.png $out/share/icons/hicolor/256x256@2/apps/cinny.png
install -DT icons/128x128.png $out/share/icons/hicolor/128x128/apps/cinny.png
install -DT icons/32x32.png $out/share/icons/hicolor/32x32/apps/cinny.png
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
mkdir -p "$out/Applications/"
cp -r "target/${rust.envVars.rustHostPlatform}/release/bundle/macos/Cinny.app" "$out/Applications/"
lib.optionalString stdenv.hostPlatform.isDarwin ''
ln -sf "$out/Applications/Cinny.app/Contents/MacOS/Cinny" "$out/bin/cinny"
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
desktop-file-edit \
--set-comment "Yet another matrix client for desktop" \
--set-key="Categories" --set-value="Network;InstantMessaging;" \
$out/share/applications/cinny.desktop
'';
nativeBuildInputs = [
copyDesktopItems
wrapGAppsHook3
pkg-config
cargo-tauri
cargo-tauri.hook
desktop-file-utils
];
buildInputs =
@@ -97,20 +90,6 @@ rustPlatform.buildRustPackage rec {
darwin.apple_sdk.frameworks.WebKit
];
desktopItems = lib.optionals stdenv.hostPlatform.isLinux [
(makeDesktopItem {
name = "cinny";
exec = "cinny";
icon = "cinny";
desktopName = "Cinny";
comment = meta.description;
categories = [
"Network"
"InstantMessaging"
];
})
];
meta = {
description = "Yet another matrix client for desktop";
homepage = "https://github.com/cinnyapp/cinny-desktop";
+1 -28
View File
@@ -56,7 +56,7 @@ buildRustPackage rec {
[
pnpm_9.configHook
nodejs
cargo-tauri
cargo-tauri.hook
pkg-config
]
++ lib.optionals stdenv.hostPlatform.isLinux [ wrapGAppsHook3 ]
@@ -77,35 +77,8 @@ buildRustPackage rec {
darwin.apple_sdk_11_0.frameworks.WebKit
];
# remove once cargo-tauri.hook becomes available
# https://github.com/NixOS/nixpkgs/pull/335751
buildPhase = ''
runHook preBuild
cargo tauri build --bundles ${if stdenv.hostPlatform.isDarwin then "app" else "deb"}
runHook postBuild
'';
doCheck = false; # many scoring tests fail
# remove once cargo-tauri.hook becomes available
installPhase = ''
runHook preInstall
${lib.optionalString stdenv.hostPlatform.isDarwin ''
mkdir -p "$out"/Applications
cp -r src-tauri/target/release/bundle/macos/* "$out"/Applications
''}
${lib.optionalString stdenv.hostPlatform.isLinux ''
mkdir -p "$out"
cp -r src-tauri/target/release/bundle/deb/*/data/usr/* "$out"
''}
runHook postInstall
'';
postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
makeWrapper "$out"/Applications/en-croissant.app/Contents/MacOS/en-croissant $out/bin/en-croissant
'';
+17 -32
View File
@@ -18,10 +18,12 @@
libsoup,
moreutils,
openssl,
rust,
webkitgtk,
nix-update-script,
cacert,
}:
rustPlatform.buildRustPackage rec {
pname = "gitbutler";
version = "0.12.16";
@@ -33,11 +35,10 @@ rustPlatform.buildRustPackage rec {
hash = "sha256-L4PVaNb3blpLIcyA7XLc71qwUPUADclxvbOkq1Jc1no=";
};
# deactivate the upstream updater in tauri configuration
# TODO: use `tauri build`'s `--config` flag with the release configuration instead of manually merging
# them. it doesn't seem to like using paths currently, even though it should.
# deactivate the upstream updater in tauri configuration & set the version
postPatch = ''
jq --slurp ".[0] * .[1] | .tauri.updater.active = false" crates/gitbutler-tauri/tauri.conf{,.release}.json | sponge crates/gitbutler-tauri/tauri.conf.json
tauri_conf="crates/gitbutler-tauri/tauri.conf.release.json"
jq '.package.version = "${version}" | .tauri.updater.active = false' "$tauri_conf" | sponge "$tauri_conf"
'';
cargoLock = {
@@ -54,7 +55,7 @@ rustPlatform.buildRustPackage rec {
};
nativeBuildInputs = [
cargo-tauri
cargo-tauri.hook
desktop-file-utils
jq
moreutils
@@ -82,7 +83,15 @@ rustPlatform.buildRustPackage rec {
]
);
# extended release configuration
tauriBuildFlags = [ "--config crates/gitbutler-tauri/tauri.conf.release.json" ];
env = {
# make sure `crates/gitbutler-tauri/inject-git-binaries.sh` can find our
# target dir
# https://github.com/gitbutlerapp/gitbutler/blob/56b64d778042d0e93fa362f808c35a7f095ab1d1/crates/gitbutler-tauri/inject-git-binaries.sh#L10C10-L10C26
TRIPLE_OVERRIDE = rust.envVars.rustHostPlatformSpec;
# `pnpm`'s `fetchDeps` and `configHook` uses a specific version of pnpm, not upstream's
COREPACK_ENABLE_STRICT = 0;
@@ -95,14 +104,6 @@ rustPlatform.buildRustPackage rec {
# we also need to have `tracing` support in `tokio` for `console-subscriber`
RUSTFLAGS = "--cfg tokio_unstable";
tauriBundle =
{
Linux = "deb";
Darwin = "app";
}
.${stdenv.hostPlatform.uname.system}
or (throw "No tauri bundle available for ${stdenv.hostPlatform.uname.system}");
ESBUILD_BINARY_PATH = lib.getExe (
esbuild.override {
buildGoModule =
@@ -128,39 +129,23 @@ rustPlatform.buildRustPackage rec {
OPENSSL_NO_VENDOR = true;
};
buildPhase = ''
runHook preBuild
preBuild = ''
pushd packages/ui
pnpm package
popd
cargo tauri build --bundles "$tauriBundle"
runHook postBuild
'';
installPhase =
''
runHook preInstall
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
mkdir -p $out/bin
cp -r target/release/bundle/macos $out/Applications
postInstall =
lib.optionalString stdenv.hostPlatform.isDarwin ''
mv $out/Applications/GitButler.app/Contents/MacOS/GitButler $out/bin/git-butler
ln -s $out/bin/git-butler $out/Applications/GitButler.app/Contents/MacOS/GitButler
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
cp -r target/release/bundle/"$tauriBundle"/*/data/usr $out
desktop-file-edit \
--set-comment "A Git client for simultaneous branches on top of your existing workflow." \
--set-key="Keywords" --set-value="git;" \
--set-key="StartupWMClass" --set-value="GitButler" \
$out/share/applications/git-butler.desktop
''
+ ''
runHook postInstall
'';
# the `gitbutler-git` crate's checks do not support release mode
+8 -24
View File
@@ -1,16 +1,15 @@
{ lib
, fetchFromGitHub
, copyDesktopItems
, stdenv
, rustc
, rustPlatform
, cargo
, cargo-tauri
, desktop-file-utils
, openssl
, libayatana-appindicator
, webkitgtk
, pkg-config
, makeDesktopItem
, pnpm
, nodejs
}:
@@ -49,10 +48,10 @@ stdenv.mkDerivation (finalAttrs: {
rustPlatform.cargoSetupHook
cargo
rustc
cargo-tauri
cargo-tauri.hook
desktop-file-utils
nodejs
pnpm.configHook
copyDesktopItems
pkg-config
];
@@ -62,28 +61,13 @@ stdenv.mkDerivation (finalAttrs: {
webkitgtk
];
preBuild = ''
cargo tauri build -b deb
postInstall = lib.optionalString stdenv.isLinux ''
desktop-file-edit \
--set-comment "An UNOFFICIAL cross-platform KakaoTalk client" \
--set-key="Categories" --set-value="Network;InstantMessaging;" \
$out/share/applications/kiwi-talk.desktop
'';
preInstall = ''
mv target/release/bundle/deb/*/data/usr/ $out
# delete the generated desktop entry
rm -r $out/share/applications
'';
desktopItems = [
(makeDesktopItem {
name = "KiwiTalk";
exec = "kiwi-talk";
icon = "kiwi-talk";
desktopName = "KiwiTalk";
comment = "An UNOFFICIAL cross-platform KakaoTalk client";
categories = [ "Network" "InstantMessaging" ];
terminal = false;
})
];
meta = with lib; {
description = "UNOFFICIAL cross-platform KakaoTalk client written in TypeScript & Rust (SolidJS, tauri)";
homepage = "https://github.com/KiwiTalk/KiwiTalk";
@@ -76,7 +76,7 @@ rustPlatform.buildRustPackage {
});
nativeBuildInputs = [
cargo-tauri
cargo-tauri.hook
desktop-file-utils
pnpm_8
nodejs
@@ -100,14 +100,6 @@ rustPlatform.buildRustPackage {
);
env = {
tauriBundle =
{
Linux = "deb";
Darwin = "app";
}
.${stdenv.hostPlatform.uname.system}
or (builtins.throw "No tauri bundle available for ${stdenv.hostPlatform.uname.system}!");
ESBUILD_BINARY_PATH = lib.getExe (
esbuild.override {
buildGoModule = args: buildGoModule (args // rec {
@@ -137,26 +129,12 @@ rustPlatform.buildRustPackage {
popd
'';
buildPhase = ''
runHook preBuild
cargo tauri build --bundles "$tauriBundle"
runHook postBuild
'';
installPhase =
''
runHook preInstall
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
mkdir -p "$out"/bin
cp -r target/release/bundle/macos "$out"/Applications
postInstall =
lib.optionalString stdenv.hostPlatform.isDarwin ''
mv "$out"/Applications/Modrinth\ App.app/Contents/MacOS/Modrinth\ App "$out"/bin/modrinth-app
ln -s "$out"/bin/modrinth-app "$out"/Applications/Modrinth\ App.app/Contents/MacOS/Modrinth\ App
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
cp -r target/release/bundle/"$tauriBundle"/*/data/usr "$out"
desktop-file-edit \
--set-comment "Modrinth's game launcher" \
--set-key="StartupNotify" --set-value="true" \
@@ -164,9 +142,6 @@ rustPlatform.buildRustPackage {
--set-key="Keywords" --set-value="game;minecraft;mc;" \
--set-key="StartupWMClass" --set-value="ModrinthApp" \
$out/share/applications/modrinth-app.desktop
''
+ ''
runHook postInstall
'';
passthru = {
+3 -13
View File
@@ -40,7 +40,7 @@ stdenv.mkDerivation (finalAttrs: {
rustPlatform.cargoSetupHook
cargo
rustc
cargo-tauri
cargo-tauri.hook
pkg-config
wrapGAppsHook3
];
@@ -62,6 +62,7 @@ stdenv.mkDerivation (finalAttrs: {
};
cargoRoot = "src-tauri";
buildAndTestSubdir = finalAttrs.cargoRoot;
cargoDeps = rustPlatform.fetchCargoTarball {
inherit (finalAttrs) pname version src;
@@ -69,19 +70,8 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-H8TMpYFJWp227jPA5H2ZhSqTMiT/U6pT6eLyjibuoLU=";
};
buildPhase = ''
runHook preBuild
cargo-tauri build -b deb
runHook postBuild
'';
installPhase = ''
runHook preInstall
postInstall = ''
install -Dm644 ${./80-mouse-actions.rules} $out/etc/udev/rules.d/80-mouse-actions.rules
cp -r src-tauri/target/release/bundle/deb/*/data/usr/* $out
runHook postInstall
'';
meta = {
+1 -10
View File
@@ -60,7 +60,7 @@ stdenv.mkDerivation (finalAttrs: {
rustPlatform.cargoSetupHook
cargo
rustc
cargo-tauri
cargo-tauri.hook
nodejs
pnpm.configHook
wrapGAppsHook3
@@ -101,15 +101,6 @@ stdenv.mkDerivation (finalAttrs: {
chmod +w ..
'';
preBuild = ''
# Use cargo-tauri from nixpkgs instead of pnpm tauri from npm
cargo tauri build -b deb
'';
preInstall = ''
mv target/release/bundle/deb/*/data/usr/ $out
'';
meta = with lib; {
description = "Cross-platform translation software";
mainProgram = "pot";
+6 -6
View File
@@ -1,7 +1,7 @@
diff --git a/Cargo.lock b/Cargo.lock
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index 55f480a8..a69f9ed9 100644
--- a/Cargo.lock
+++ b/Cargo.lock
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -1839,6 +1839,22 @@ dependencies = [
"tower-service",
]
@@ -133,10 +133,10 @@ index 55f480a8..a69f9ed9 100644
[[package]]
name = "tokio-rustls"
version = "0.25.0"
diff --git a/Cargo.toml b/Cargo.toml
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 3e3ab7ee..b6612f95 100644
--- a/Cargo.toml
+++ b/Cargo.toml
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -28,6 +28,8 @@ time = { version = "0.3", default-features = false}
log = "^0.4"
url = "2"
+13 -50
View File
@@ -18,12 +18,10 @@
, rustc
, rustPlatform
, stdenv
, stdenvNoCC
, webkitgtk_4_1
}:
let
cargo-tauri_2 = let
version = "2.0.0-rc.3";
src = fetchFromGitHub {
@@ -68,8 +66,6 @@ in stdenv.mkDerivation (finalAttrs: {
hash = "sha256-jOjOdrVOcGPenFW5mkkXKA64C6c+/f9KzlvtUmw6vXc=";
};
sourceRoot = "${finalAttrs.src.name}/src-tauri";
# HACK: A dependency (surrealist -> tauri -> **reqwest**) contains hyper-tls
# as an actually optional dependency. It ends up in the `Cargo.lock` file of
# tauri, but not in the one of surrealist. We apply a patch to `Cargo.toml`
@@ -80,47 +76,25 @@ in stdenv.mkDerivation (finalAttrs: {
./0001-Cargo.patch
];
ui = stdenvNoCC.mkDerivation {
inherit (finalAttrs) src version;
pname = "${finalAttrs.pname}-ui";
pnpmDeps = pnpm.fetchDeps {
inherit (finalAttrs) pname version src;
hash = "sha256-zGs1MWJ8TEFuHOoekCNIKQo2PBnp95xLz+R8mzeJXh8=";
};
ESBUILD_BINARY_PATH = lib.getExe esbuild_21-5;
nativeBuildInputs = [ nodejs pnpm.configHook ];
buildPhase = ''
runHook preBuild
pnpm build:desktop
runHook postBuild
'';
installPhase = ''
runHook preInstall
cp -r dist $out
runHook postInstall
'';
};
cargoDeps = rustPlatform.fetchCargoTarball {
inherit (finalAttrs) patches src sourceRoot;
inherit (finalAttrs) patches src;
sourceRoot = finalAttrs.cargoRoot;
name = "${finalAttrs.pname}-${finalAttrs.version}";
hash = "sha256-LtQS0kH+2P4odV7BJYiH6T51+iZHAM9W9mV96rNfNWs=";
};
pnpmDeps = pnpm.fetchDeps {
inherit (finalAttrs) pname version src;
hash = "sha256-zGs1MWJ8TEFuHOoekCNIKQo2PBnp95xLz+R8mzeJXh8=";
};
nativeBuildInputs = [
cargo
cargo-tauri_2
(cargo-tauri.hook.override { cargo-tauri = cargo-tauri_2; })
gobject-introspection
makeBinaryWrapper
nodejs
pnpm.configHook
pkg-config
rustc
rustPlatform.cargoSetupHook
@@ -136,23 +110,12 @@ in stdenv.mkDerivation (finalAttrs: {
];
env = {
ESBUILD_BINARY_PATH = lib.getExe esbuild_21-5;
OPENSSL_NO_VENDOR = 1;
};
postPatch = ''
substituteInPlace ./tauri.conf.json \
--replace-fail '"frontendDist": "../dist",' '"frontendDist": "${finalAttrs.ui}",' \
--replace-fail '"beforeBuildCommand": "pnpm build:desktop",' '"beforeBuildCommand": "",'
'';
postBuild = ''
cargo tauri build --bundles deb
'';
postInstall = ''
install -Dm555 target/release/bundle/deb/Surrealist_${finalAttrs.version}_*/data/usr/bin/surrealist -t $out/bin
cp -r target/release/bundle/deb/Surrealist_${finalAttrs.version}_*/data/usr/share $out
'';
cargoRoot = "src-tauri";
buildAndTestSubdir = finalAttrs.cargoRoot;
postFixup = ''
wrapProgram "$out/bin/surrealist" \
-1
View File
@@ -15799,7 +15799,6 @@ with pkgs;
cargo-ui = callPackage ../development/tools/rust/cargo-ui { };
cargo-unused-features = callPackage ../development/tools/rust/cargo-unused-features { };
cargo-tauri = callPackage ../development/tools/rust/cargo-tauri { };
cargo-mobile2 = callPackage ../development/tools/rust/cargo-mobile2 { };
cargo-valgrind = callPackage ../development/tools/rust/cargo-valgrind { };