nixpkgs/pkgs/by-name/ca/cargo-mobile2/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

55 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.4";
in
rustPlatform.buildRustPackage {
inherit pname version;
src = fetchFromGitHub {
owner = "tauri-apps";
repo = pname;
rev = "cargo-mobile2-v${version}";
hash = "sha256-1lrimBdJwur5b4wB8hZVUtJEbgXoib0ytzjzhkqNE6c=";
};
# 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-vmoR5pA8CNf4eZpQgj0Wn1/FmId4hmpSi7FYxBY5O9M=";
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 ];
};
}