nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 97 lines 2.8 kB view raw
1{ 2 lib, 3 stdenv, 4 rustPlatform, 5 fetchFromGitHub, 6 installShellFiles, 7 makeBinaryWrapper, 8 pkg-config, 9 libgit2, 10 zlib, 11 buildPackages, 12 versionCheckHook, 13 withClipboard ? true, 14 withTrash ? !stdenv.hostPlatform.isDarwin, 15}: 16 17rustPlatform.buildRustPackage (finalAttrs: { 18 pname = "broot"; 19 version = "1.47.0"; 20 21 src = fetchFromGitHub { 22 owner = "Canop"; 23 repo = "broot"; 24 tag = "v${finalAttrs.version}"; 25 hash = "sha256-BX54J43bUa73WCxCmYQ2VgXhURRiJG5Do1ofsFFY38Y="; 26 }; 27 28 cargoHash = "sha256-7F93oPDXHznwkZZVqdgEuIb5sxa7uElBkwUr/PDIsdo="; 29 30 nativeBuildInputs = [ 31 installShellFiles 32 makeBinaryWrapper 33 pkg-config 34 ]; 35 36 buildInputs = [ 37 libgit2 38 ] 39 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 40 zlib 41 ]; 42 43 buildFeatures = lib.optionals withTrash [ "trash" ] ++ lib.optionals withClipboard [ "clipboard" ]; 44 45 env.RUSTONIG_SYSTEM_LIBONIG = true; 46 47 postPatch = '' 48 # Fill the version stub in the man page. We can't fill the date 49 # stub reproducibly. 50 substitute man/page man/broot.1 \ 51 --replace-fail "#version" "${finalAttrs.version}" 52 ''; 53 54 postInstall = 55 lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) '' 56 # Install shell function for bash. 57 ${stdenv.hostPlatform.emulator buildPackages} $out/bin/broot --print-shell-function bash > br.bash 58 install -Dm0444 -t $out/etc/profile.d br.bash 59 60 # Install shell function for zsh. 61 ${stdenv.hostPlatform.emulator buildPackages} $out/bin/broot --print-shell-function zsh > br.zsh 62 install -Dm0444 br.zsh $out/share/zsh/site-functions/br 63 64 # Install shell function for fish 65 ${stdenv.hostPlatform.emulator buildPackages} $out/bin/broot --print-shell-function fish > br.fish 66 install -Dm0444 -t $out/share/fish/vendor_functions.d br.fish 67 68 '' 69 + '' 70 # install shell completion files 71 OUT_DIR=$releaseDir/build/broot-*/out 72 73 installShellCompletion --bash $OUT_DIR/{br,broot}.bash 74 installShellCompletion --fish $OUT_DIR/{br,broot}.fish 75 installShellCompletion --zsh $OUT_DIR/{_br,_broot} 76 77 installManPage man/broot.1 78 79 # Do not nag users about installing shell integration, since 80 # it is impure. 81 wrapProgram $out/bin/broot \ 82 --set BR_INSTALL no 83 ''; 84 85 doInstallCheck = true; 86 nativeInstallCheckInputs = [ versionCheckHook ]; 87 versionCheckProgramArg = "--version"; 88 89 meta = with lib; { 90 description = "Interactive tree view, a fuzzy search, a balanced BFS descent and customizable commands"; 91 homepage = "https://dystroy.org/broot/"; 92 changelog = "https://github.com/Canop/broot/releases/tag/v${finalAttrs.version}"; 93 maintainers = with maintainers; [ dywedir ]; 94 license = with licenses; [ mit ]; 95 mainProgram = "broot"; 96 }; 97})