Skip to content

Commit

Permalink
cargo-tauri{,_1}: utilize better finalAttrs support
Browse files Browse the repository at this point in the history
  • Loading branch information
TomaSajt committed Nov 16, 2024
1 parent b43012a commit 55e78c0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 37 deletions.
16 changes: 8 additions & 8 deletions pkgs/by-name/ca/cargo-tauri/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
webkitgtk_4_1,
}:

rustPlatform.buildRustPackage rec {
rustPlatform.buildRustPackage (finalAttrs: {
pname = "tauri";
version = "2.1.0";

src = fetchFromGitHub {
owner = "tauri-apps";
repo = "tauri";
rev = "refs/tags/tauri-v${version}";
rev = "refs/tags/tauri-v${finalAttrs.version}";
hash = "sha256-n1rSffVef9G9qtLyheuK5k6anAHsZANSu0C73QDdg2o=";
};

Expand All @@ -41,15 +41,15 @@ rustPlatform.buildRustPackage rec {
];

cargoBuildFlags = [ "--package tauri-cli" ];
cargoTestFlags = cargoBuildFlags;
cargoTestFlags = finalAttrs.cargoBuildFlags;

passthru = {
# See ./doc/hooks/tauri.section.md
hook = callPackage ./hook.nix { };
hook = callPackage ./hook.nix { cargo-tauri = finalAttrs.finalPackage; };

tests = {
hook = callPackage ./test-app.nix { };
version = testers.testVersion { package = cargo-tauri; };
hook = callPackage ./test-app.nix { cargo-tauri = finalAttrs.finalPackage; };
version = testers.testVersion { package = finalAttrs.finalPackage; };
};

updateScript = nix-update-script {
Expand All @@ -63,7 +63,7 @@ rustPlatform.buildRustPackage rec {
meta = {
description = "Build smaller, faster, and more secure desktop applications with a web frontend";
homepage = "https://tauri.app/";
changelog = "https://github.com/tauri-apps/tauri/releases/tag/tauri-v${version}";
changelog = "https://github.com/tauri-apps/tauri/releases/tag/tauri-v${finalAttrs.version}";
license = with lib.licenses; [
asl20 # or
mit
Expand All @@ -75,4 +75,4 @@ rustPlatform.buildRustPackage rec {
];
mainProgram = "cargo-tauri";
};
}
})
37 changes: 8 additions & 29 deletions pkgs/by-name/ca/cargo-tauri_1/package.nix
Original file line number Diff line number Diff line change
@@ -1,40 +1,34 @@
{
lib,
stdenv,
rustPlatform,
fetchFromGitHub,
cargo-tauri,
cargo-tauri_1,
gtk3,
libsoup,
openssl,
webkitgtk_4_0,
}:

cargo-tauri.overrideAttrs (
newAttrs: oldAttrs: {
finalAttrs: prevAttrs: {
version = "1.8.1";

src = fetchFromGitHub {
owner = "tauri-apps";
repo = "tauri";
rev = "tauri-v${newAttrs.version}";
rev = "tauri-v${finalAttrs.version}";
hash = "sha256-z8dfiLghN6m95PLCMDgpBMNo+YEvvsGN9F101fAcVF4=";
};

# Manually specify the sourceRoot since this crate depends on other crates in the workspace. Relevant info at
# https://discourse.nixos.org/t/difficulty-using-buildrustpackage-with-a-src-containing-multiple-cargo-workspaces/10202
sourceRoot = "${newAttrs.src.name}/tooling/cli";
sourceRoot = "${finalAttrs.src.name}/tooling/cli";

cargoDeps = rustPlatform.fetchCargoTarball {
inherit (newAttrs)
pname
version
src
sourceRoot
;
hash = "sha256-OIXC4kwGIemIL8KaqK5SUDZZrOX3PX0w3h9bNiM/pCw=";
};
cargoHash = "sha256-OIXC4kwGIemIL8KaqK5SUDZZrOX3PX0w3h9bNiM/pCw=";

passthru.cargoLock = null; # don't inherit the cargoLock file

passthru.tests = lib.removeAttrs prevAttrs.passthru.tests [ "hook" ];

buildInputs =
[ openssl ]
Expand All @@ -43,20 +37,5 @@ cargo-tauri.overrideAttrs (
libsoup
webkitgtk_4_0
];

passthru = {
hook = cargo-tauri.hook.override { cargo-tauri = cargo-tauri_1; };
};

meta = {
inherit (oldAttrs.meta)
description
homepage
changelog
license
maintainers
mainProgram
;
};
}
)

0 comments on commit 55e78c0

Please sign in to comment.