From 820b73e0d8452a7953d282d262361794ac1c6ffd Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 22 Jul 2025 22:42:17 +0300 Subject: [PATCH] nix: link multicall binaries with cargo-xtask --- nix/package.nix | 18 ++++++++++++++++++ nix/shell.nix | 3 +++ 2 files changed, 21 insertions(+) diff --git a/nix/package.nix b/nix/package.nix index 7a91195..afa39dc 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -1,6 +1,7 @@ { lib, rustPlatform, + stdenv, }: rustPlatform.buildRustPackage (finalAttrs: { pname = "eh"; @@ -21,11 +22,28 @@ rustPlatform.buildRustPackage (finalAttrs: { ]); }; + # xtask doesn't support passing --targe + # but nix hooks expect the folder structure from when it's set + env.CARGO_BUILD_TARGET = stdenv.hostPlatform.rust.cargoShortTarget; cargoLock.lockFile = "${finalAttrs.src}/Cargo.lock"; enableParallelBuilding = true; + postInstall = '' + # Install required files with the 'dist' task + $out/bin/xtask multicall \ + --bin-dir $out/bin \ + --main-binary $out/bin/eh + + # The xtask output has been built as a part of the build phase. If + # we don't remove it, it'll be linked in $out/bin alongside the actual + # binary and populate $PATH with a dedicated 'xtask' command. Remove. + rm -rf $out/bin/xtask + ''; + meta = { description = "Ergonomic Nix CLI helper"; maintainers = with lib.licenses; [NotAShelf]; + license = lib.licenses.mpl20; + mainProgram = "eh"; }; }) diff --git a/nix/shell.nix b/nix/shell.nix index 965a0eb..fcda3a5 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -4,6 +4,7 @@ rustfmt, clippy, cargo, + taplo, rustPlatform, }: mkShell { @@ -13,6 +14,8 @@ mkShell { rustfmt clippy cargo + + taplo ]; RUST_SRC_PATH = "${rustPlatform.rustLibSrc}";