nixpkgs/pkgs/tools/networking/bandwhich/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

66 lines
2.0 KiB
Nix

{ lib, stdenv, fetchFromGitHub, rustPlatform, Security, installShellFiles }:
rustPlatform.buildRustPackage rec {
pname = "bandwhich";
version = "0.23.0";
src = fetchFromGitHub {
owner = "imsnif";
repo = pname;
rev = "v${version}";
hash = "sha256-8PUtlhy8rsQw3TqgpxWiVettGhncHetWCZcrDXjsR5M=";
};
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"packet-builder-0.7.0" = "sha256-KxNrnLZ/z3JJ3E1pCTJF9tNXI7XYNRc6ooTUz3avpjw=";
};
};
checkFlags = [
# failing in upstream CI
"--skip=tests::cases::ui::layout_under_50_width_under_50_height"
];
nativeBuildInputs = [ installShellFiles ];
buildInputs = lib.optional stdenv.hostPlatform.isDarwin Security;
# 10 passed; 47 failed https://hydra.nixos.org/build/148943783/nixlog/1
doCheck = !stdenv.hostPlatform.isDarwin;
postPatch = ''
ln --force -s ${./Cargo.lock} Cargo.lock
'';
preConfigure = ''
export BANDWHICH_GEN_DIR=_shell-files
mkdir -p $BANDWHICH_GEN_DIR
'';
postInstall = ''
installManPage $BANDWHICH_GEN_DIR/bandwhich.1
installShellCompletion $BANDWHICH_GEN_DIR/bandwhich.{bash,fish} \
--zsh $BANDWHICH_GEN_DIR/_bandwhich
'';
meta = with lib; {
description = "CLI utility for displaying current network utilization";
longDescription = ''
bandwhich sniffs a given network interface and records IP packet size, cross
referencing it with the /proc filesystem on linux or lsof on MacOS. It is
responsive to the terminal window size, displaying less info if there is
no room for it. It will also attempt to resolve ips to their host name in
the background using reverse DNS on a best effort basis.
'';
homepage = "https://github.com/imsnif/bandwhich";
changelog = "https://github.com/imsnif/bandwhich/blob/${src.rev}/CHANGELOG.md";
license = licenses.mit;
maintainers = with maintainers; [ Br1ght0ne figsoda ];
platforms = platforms.unix;
mainProgram = "bandwhich";
};
}