gh-f: cleanup

- Use `propagatedUserEnvPkgs`
- Add `nix-update-script`
- `finalAttrs` pattern
This commit is contained in:
Yiyu Zhou 2025-08-15 01:27:10 -07:00
parent 6fa44511c7
commit 6caf19dc2f

View File

@ -2,7 +2,7 @@
lib, lib,
fetchFromGitHub, fetchFromGitHub,
stdenvNoCC, stdenvNoCC,
makeWrapper, makeBinaryWrapper,
gh, gh,
fzf, fzf,
coreutils, coreutils,
@ -10,48 +10,55 @@
gnused, gnused,
withBat ? false, withBat ? false,
bat, bat,
nix-update-script,
}: }:
let
binPath = lib.makeBinPath ( stdenvNoCC.mkDerivation (finalAttrs: {
[
gh
fzf
coreutils
gawk
gnused
]
++ lib.optional withBat bat
);
in
stdenvNoCC.mkDerivation rec {
pname = "gh-f"; pname = "gh-f";
version = "1.4.1"; version = "1.4.1";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "gennaro-tedesco"; owner = "gennaro-tedesco";
repo = "gh-f"; repo = "gh-f";
rev = "v${version}"; tag = "v${finalAttrs.version}";
hash = "sha256-Jf7sDn/iRB/Lwz21fGLRduvt9/9cs5FFMhazULgj1ik="; hash = "sha256-Jf7sDn/iRB/Lwz21fGLRduvt9/9cs5FFMhazULgj1ik=";
}; };
nativeBuildInputs = [ nativeBuildInputs = [ makeBinaryWrapper ];
makeWrapper
]; propagatedUserEnvPkgs = [
gh
fzf
coreutils
gawk
gnused
]
++ lib.optional withBat bat;
installPhase = '' installPhase = ''
runHook preInstall
install -D -m755 "gh-f" "$out/bin/gh-f" install -D -m755 "gh-f" "$out/bin/gh-f"
runHook postInstall
''; '';
postFixup = '' postFixup = ''
wrapProgram "$out/bin/gh-f" --prefix PATH : "${binPath}" wrapProgram "$out/bin/gh-f" \
--suffix PATH : ${lib.makeBinPath finalAttrs.propagatedUserEnvPkgs}
''; '';
meta = with lib; { passthru.updateScript = nix-update-script { };
meta = {
homepage = "https://github.com/gennaro-tedesco/gh-f"; homepage = "https://github.com/gennaro-tedesco/gh-f";
description = "GitHub CLI ultimate FZF extension"; description = "GitHub CLI ultimate FZF extension";
maintainers = with maintainers; [ loicreynier ]; license = lib.licenses.unlicense;
license = licenses.unlicense;
mainProgram = "gh-f"; mainProgram = "gh-f";
platforms = platforms.all; platforms = lib.platforms.all;
maintainers = with lib.maintainers; [
loicreynier
yiyu
];
}; };
} })