gitbutler: use cargo-tauri.hook

This commit is contained in:
seth 2024-08-18 05:56:15 -04:00
parent 154d776f51
commit 43256320c5
No known key found for this signature in database
GPG Key ID: D31BD0D494BBEE86

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