depot/third_party/nixpkgs/pkgs/development/tools/rust/cargo-mobile2/default.nix
Default email 472aeafc57 Project import generated by Copybara.
GitOrigin-RevId: c31898adf5a8ed202ce5bea9f347b1c6871f32d1
2024-10-04 18:56:33 +02:00

54 lines
1.4 KiB
Nix

{ lib
, stdenv
, rustPlatform
, fetchFromGitHub
, pkg-config
, openssl
, git
, darwin
, makeWrapper
}:
let
inherit (darwin.apple_sdk.frameworks) CoreServices;
pname = "cargo-mobile2";
version = "0.17.3";
in
rustPlatform.buildRustPackage {
inherit pname version;
src = fetchFromGitHub {
owner = "tauri-apps";
repo = pname;
rev = "cargo-mobile2-v${version}";
hash = "sha256-DOV4QjtjOH1420KH70kkISo9lNbcjbnAn34MnAJWYvQ=";
};
# 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 = "${src.name}/tooling/cli";
cargoHash = "sha256-aC6IxamPHRZ1V6ZTiXGVSt4YIa+GPK/j6IWh86JOrV8=";
preBuild = ''
mkdir -p $out/share/
# during the install process tauri-mobile puts templates and commit information in CARGO_HOME
export CARGO_HOME=$out/share/
'';
buildInputs = [ openssl ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ CoreServices ];
nativeBuildInputs = [ pkg-config git makeWrapper ];
preFixup = ''
for bin in $out/bin/cargo-*; do
wrapProgram $bin \
--set CARGO_HOME "$out/share"
done
'';
meta = with lib; {
description = "Rust on mobile made easy!";
homepage = "https://tauri.app/";
license = with licenses; [ asl20 /* or */ mit ];
maintainers = with maintainers; [ happysalada ];
};
}