packages: refactor cargo rust packages

This commit is contained in:
Primrose 2025-07-28 12:11:02 +02:00
parent 318ca4fbc6
commit b9639eb49c
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA
4 changed files with 42 additions and 34 deletions

View file

@ -1,11 +1,13 @@
{ {
lib,
rustPlatform, rustPlatform,
fetchFromGitea, fetchFromGitea,
}: }:
rustPlatform.buildRustPackage (finalAttrs: { rustPlatform.buildRustPackage (finalAttrs: let
cargoToml = fromTOML (builtins.readFile (finalAttrs.src + "/Cargo.toml"));
cargoLock = finalAttrs.src + "/Cargo.lock";
in {
pname = "audio-lint"; pname = "audio-lint";
version = lib.substring 0 8 finalAttrs.src.rev; version = cargoToml.package.version;
src = fetchFromGitea { src = fetchFromGitea {
domain = "git.confusedcompiler.org"; domain = "git.confusedcompiler.org";
@ -15,5 +17,5 @@ rustPlatform.buildRustPackage (finalAttrs: {
hash = "sha256-h1SnWAh3FPL5GweOXVXXtp+swZApgecYaWjy7rM/J+w="; hash = "sha256-h1SnWAh3FPL5GweOXVXXtp+swZApgecYaWjy7rM/J+w=";
}; };
cargoHash = "sha256-daaNDuxS/mbADCk4X+ZOrzEeu2vrQj1gDJ9y9bMihSk="; cargoLock.lockFile = cargoLock;
}) })

View file

@ -8,6 +8,7 @@
}: }:
rustPlatform.buildRustPackage (finalAttrs: let rustPlatform.buildRustPackage (finalAttrs: let
cargoToml = fromTOML (builtins.readFile (finalAttrs.src + "/Cargo.toml")); cargoToml = fromTOML (builtins.readFile (finalAttrs.src + "/Cargo.toml"));
cargoLock = finalAttrs.src + "/Cargo.lock";
in { in {
pname = "emoji-picker"; pname = "emoji-picker";
version = cargoToml.package.version; version = cargoToml.package.version;
@ -19,7 +20,7 @@ in {
hash = "sha256-ETZRqyQ5lzYA6NGOXLnxfpwb4qMMC1l7s5XA8H5s9Jw="; hash = "sha256-ETZRqyQ5lzYA6NGOXLnxfpwb4qMMC1l7s5XA8H5s9Jw=";
}; };
cargoHash = "sha256-rJKFRWaqulnan2jtt0erj5cypSBe0Z5PiNcOXd3HCZs="; cargoLock.lockFile = cargoLock;
nativeBuildInputs = [ nativeBuildInputs = [
python3 python3

View file

@ -6,34 +6,35 @@
libiconv, libiconv,
darwin, darwin,
zlib, zlib,
}: let }:
rev = "v13.0.0-alpha.8"; rustPlatform.buildRustPackage (finalAttrs: let
in cargoToml = fromTOML (builtins.readFile (finalAttrs.src + "/Cargo.toml"));
rustPlatform.buildRustPackage { cargoLock = finalAttrs.src + "/Cargo.lock";
pname = "tokei"; in {
version = rev; pname = "tokei";
version = cargoToml.package.version;
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "XAMPPRocky"; owner = "XAMPPRocky";
repo = "tokei"; repo = "tokei";
inherit rev; rev = "v13.0.0-alpha.8";
hash = "sha256-jCI9VM3y76RI65E5UGuAPuPkDRTMyi+ydx64JWHcGfE="; hash = "sha256-jCI9VM3y76RI65E5UGuAPuPkDRTMyi+ydx64JWHcGfE=";
}; };
cargoHash = "sha256-LzlyrKaRjUo6JnVLQnHidtI4OWa+GrhAc4D8RkL+nmQ="; cargoLock.lockFile = cargoLock;
patches = [ patches = [
./skel.patch ./skel.patch
./why3.patch ./why3.patch
]; ];
buildInputs = lib.optionals stdenv.isDarwin [ buildInputs = lib.optionals stdenv.isDarwin [
libiconv libiconv
darwin.Security darwin.Security
]; ];
checkInputs = lib.optionals stdenv.isDarwin [zlib]; checkInputs = lib.optionals stdenv.isDarwin [zlib];
# enable all output formats # enable all output formats
buildFeatures = ["all"]; buildFeatures = ["all"];
} })

View file

@ -3,8 +3,12 @@
fetchFromGitHub, fetchFromGitHub,
fetchpatch, fetchpatch,
}: }:
rustPlatform.buildRustPackage { rustPlatform.buildRustPackage (finalAttrs: let
name = "typst-mutilate"; cargoToml = fromTOML (builtins.readFile (finalAttrs.src + "/Cargo.toml"));
cargoLock = finalAttrs.src + "/Cargo.lock";
in {
pname = "typst-mutilate";
version = cargoToml.package.version;
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "frozolotl"; owner = "frozolotl";
@ -13,7 +17,7 @@ rustPlatform.buildRustPackage {
hash = "sha256-r4fkFv1np8xhff3m8yev1rU1vfKRz8zQMIKIc+fOjew="; hash = "sha256-r4fkFv1np8xhff3m8yev1rU1vfKRz8zQMIKIc+fOjew=";
}; };
cargoHash = "sha256-QEOXPf/k+fCMNQxKGsW3FDsgH5XXUKob0XOef3DiB0s="; cargoLock.lockFile = cargoLock;
patches = [ patches = [
(fetchpatch { (fetchpatch {
@ -22,4 +26,4 @@ rustPlatform.buildRustPackage {
hash = "sha256-+6DMQo4cjVASgkX4gcYrEkwQ/uxttV/61fDnXBqbNcg="; hash = "sha256-+6DMQo4cjVASgkX4gcYrEkwQ/uxttV/61fDnXBqbNcg=";
}) })
]; ];
} })