From a94ef7f5b4ec49b3b0fc75f985b6820a16aeeea0 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 14 Oct 2025 08:39:35 +0300 Subject: [PATCH] nix: install multicall binaries in `postInstall` Signed-off-by: NotAShelf Change-Id: I6a6a69646b6afeb1d9dda8d16e00f6f39b8046ff --- nix/package.nix | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/nix/package.nix b/nix/package.nix index 0366838..3c32991 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -1,6 +1,7 @@ { lib, craneLib, + versionCheckHook, }: let pname = "stash"; version = (builtins.fromTOML (builtins.readFile ../Cargo.toml)).package.version; @@ -14,6 +15,7 @@ (fs.fileFilter (file: builtins.any file.hasExt ["rs"]) (s + /src)) (s + /Cargo.lock) (s + /Cargo.toml) + (s + /build.rs) ]; }; @@ -28,11 +30,32 @@ in strictDeps = true; + # Whether cargo's target directory should be copied as an output + doInstallCargoArtifacts = true; + # Install Systemd service for Stash into $out/share. # This can be used to use Stash in 'systemd.packages' postInstall = '' mkdir -p $out install -Dm755 ${../vendor/stash.service} $out/share/stash.service + + # Since Crane doesn't have a good way of enforcing that our symlinks + # generated by the build wrapper are correctly linked, we should link + # them *manually*. + for bin in stash-copy stash-paste wl-copy wl-paste; do + ln -sf $out/bin/stash $out/bin/$bin + done + ''; + + nativeInstallCheckInputs = [versionCheckHook]; + doInstallCheck = true; + + # After the version check, let's see if all binaries are linked correctly. + # We could probably add a check phase to the versions of each. + postInstallCheck = '' + for bin in stash stash-copy stash-paste wl-copy wl-paste; do + [ -x "$out/bin/$bin" ] || { echo "$bin missing"; exit 1; } + done ''; meta = {