{buildRustPackage,fetchCargoTarball,fetchCargoVendor}: respect cargoRoot (#350541)

This commit is contained in:
Aleksana 2024-12-03 19:49:09 +08:00 committed by GitHub
commit d6d092f87d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 22 additions and 7048 deletions

View File

@ -30,6 +30,7 @@
, cargoPatches ? []
, patches ? []
, sourceRoot ? null
, cargoRoot ? null
, logLevel ? ""
, buildInputs ? []
, nativeBuildInputs ? []
@ -72,13 +73,13 @@ let
else if cargoDeps != null then cargoDeps
else if cargoLock != null then importCargoLock cargoLock
else if useFetchCargoVendor then fetchCargoVendor ({
inherit src srcs sourceRoot preUnpack unpackPhase postUnpack;
inherit src srcs sourceRoot cargoRoot preUnpack unpackPhase postUnpack;
name = cargoDepsName;
patches = cargoPatches;
hash = args.cargoHash;
} // depsExtraArgs)
else fetchCargoTarball ({
inherit src srcs sourceRoot preUnpack unpackPhase postUnpack cargoUpdateHook;
inherit src srcs sourceRoot cargoRoot preUnpack unpackPhase postUnpack cargoUpdateHook;
name = cargoDepsName;
patches = cargoPatches;
} // lib.optionalAttrs (args ? cargoHash) {

View File

@ -85,6 +85,10 @@ stdenv.mkDerivation (
# Ensure deterministic Cargo vendor builds
export SOURCE_DATE_EPOCH=1
if [ -n "''${cargoRoot-}" ]; then
cd "$cargoRoot"
fi
if [[ ! -f Cargo.lock ]]; then
echo
echo "ERROR: The Cargo.lock file doesn't exist"

View File

@ -62,6 +62,10 @@ let
buildPhase = ''
runHook preBuild
if [ -n "''${cargoRoot-}" ]; then
cd "$cargoRoot"
fi
fetch-cargo-vendor-util create-vendor-staging ./Cargo.lock "$out"
runHook postBuild

File diff suppressed because it is too large Load Diff

View File

@ -34,16 +34,11 @@ rustPlatform.buildRustPackage rec {
hash = "sha256-hvWXSegUWJvwCU5NLb2vqnl+FIWpCLxw96s9NUIgJTI=";
};
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"tauri-plugin-log-0.0.0" = "sha256-t+zmMMSnD9ASZZvqlhu1ah2OjCUtRXdk/xaI37uI49c=";
"vampirc-uci-0.11.1" = "sha256-g2JjHZoAmmZ7xsw4YnkUPRXJxsYmBqflWxCFkFEvMXQ=";
};
};
cargoRoot = "src-tauri";
useFetchCargoVendor = true;
cargoHash = "sha256-6cBGOdJ7jz+mOl2EEXxoLNeX9meW+ybQxAxnnHAplIc=";
buildAndTestSubdir = cargoRoot;
nativeBuildInputs =

View File

@ -1,6 +1,5 @@
{
lib,
stdenv,
fetchFromGitHub,
npmHooks,
@ -8,8 +7,6 @@
nodejs,
rustPlatform,
cargo,
rustc,
cargo-tauri_1,
pkg-config,
@ -21,25 +18,22 @@
webkitgtk_4_0,
}:
stdenv.mkDerivation (finalAttrs: {
rustPlatform.buildRustPackage rec {
pname = "mouse-actions-gui";
version = "0.4.5";
src = fetchFromGitHub {
owner = "jersou";
repo = "mouse-actions";
rev = "refs/tags/v${finalAttrs.version}";
rev = "refs/tags/v${version}";
hash = "sha256-44F4CdsDHuN2FuijnpfmoFy4a/eAbYOoBYijl9mOctg=";
};
sourceRoot = "${finalAttrs.src.name}/config-editor";
sourceRoot = "${src.name}/config-editor";
nativeBuildInputs = [
npmHooks.npmConfigHook
nodejs
rustPlatform.cargoSetupHook
cargo
rustc
cargo-tauri_1.hook
pkg-config
wrapGAppsHook3
@ -57,25 +51,21 @@ stdenv.mkDerivation (finalAttrs: {
];
npmDeps = fetchNpmDeps {
inherit (finalAttrs) src sourceRoot;
inherit src sourceRoot;
hash = "sha256-amDTYAvEoDHb7+dg39+lUne0dv0M9vVe1vHoXk2agZA=";
};
cargoRoot = "src-tauri";
buildAndTestSubdir = finalAttrs.cargoRoot;
buildAndTestSubdir = cargoRoot;
cargoDeps = rustPlatform.fetchCargoTarball {
inherit (finalAttrs) pname version src;
sourceRoot = "${finalAttrs.sourceRoot}/${finalAttrs.cargoRoot}";
hash = "sha256-H8TMpYFJWp227jPA5H2ZhSqTMiT/U6pT6eLyjibuoLU=";
};
cargoHash = "sha256-H8TMpYFJWp227jPA5H2ZhSqTMiT/U6pT6eLyjibuoLU=";
postInstall = ''
install -Dm644 ${./80-mouse-actions.rules} $out/etc/udev/rules.d/80-mouse-actions.rules
'';
meta = {
changelog = "https://github.com/jersou/mouse-actions/blob/${finalAttrs.src.rev}/CHANGELOG.md";
changelog = "https://github.com/jersou/mouse-actions/blob/${src.rev}/CHANGELOG.md";
description = "Mouse event based command executor, a mix between Easystroke and Comiz edge commands";
homepage = "https://github.com/jersou/mouse-actions";
license = lib.licenses.mit;
@ -83,4 +73,4 @@ stdenv.mkDerivation (finalAttrs: {
maintainers = with lib.maintainers; [ tomasajt ];
platforms = lib.platforms.linux;
};
})
}