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 = {