findup: use zigHook

Also, a cosmetic refactor:

- Reorder parameter listing
- Use rec-less, overlay-style overridable recursive attributes (in effect since
NixOS#119942);
- Remove nested with (according to
https://nix.dev/recipes/best-practices#with-scopes)
This commit is contained in:
Anderson Torres 2023-07-10 01:29:45 -03:00
parent 30567662bb
commit a34e8fe161

View File

@ -1,39 +1,30 @@
{ lib, stdenv, fetchFromGitHub, zig, testers, findup }:
{ lib
, stdenv
, fetchFromGitHub
, findup
, testers
, zigHook
}:
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "findup";
version = "1.1.1";
src = fetchFromGitHub {
owner = "booniepepper";
repo = pname;
rev = "v${version}";
sha256 = "sha256-Tpyiy5oJQ04lqVEOFshFC0+90VoNILQ+N6Dd7lbuH/Q=";
repo = "findup";
rev = "v${finalAttrs.version}";
hash = "sha256-Tpyiy5oJQ04lqVEOFshFC0+90VoNILQ+N6Dd7lbuH/Q=";
};
nativeBuildInputs = [ zig ];
nativeBuildInputs = [ zigHook ];
# Builds and installs (at the same time) with Zig.
dontConfigure = true;
dontBuild = true;
passthru.tests.version = testers.testVersion { package = finalAttrs.findup; };
# Give Zig a directory for intermediate work.
preInstall = ''
export HOME=$TMPDIR
'';
installPhase = ''
runHook preInstall
zig build -Drelease-safe -Dcpu=baseline --prefix $out
runHook postInstall
'';
passthru.tests.version = testers.testVersion { package = findup; };
meta = with lib; {
meta = {
homepage = "https://github.com/booniepepper/findup";
description = "Search parent directories for sentinel files";
license = licenses.mit;
maintainers = with maintainers; [ booniepepper ];
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ booniepepper ];
};
}
})