From b95b565229c82491f1134b7e51392998802db7da Mon Sep 17 00:00:00 2001 From: Nicolas Berbiche Date: Wed, 31 Jan 2024 14:01:55 -0500 Subject: [PATCH] dev: add network debugging tools --- overlays/asroute.nix | 28 ++++++++++++++++++++ profiles/dev/home-manager/default.nix | 3 +++ profiles/dev/home-manager/neovim/default.nix | 7 +---- top-level/lib.nix | 7 +++++ 4 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 overlays/asroute.nix diff --git a/overlays/asroute.nix b/overlays/asroute.nix new file mode 100644 index 0000000..777f428 --- /dev/null +++ b/overlays/asroute.nix @@ -0,0 +1,28 @@ +final: prev: { + asroute = prev.lib.flip prev.callPackage { } ( + { stdenv + , lib + , fetchFromGitHub + , rustPlatform + }: + rustPlatform.buildRustPackage rec { + pname = "asroute"; + version = "0.1.0"; + + src = fetchFromGitHub { + repo = pname; + owner = "stevenpack"; + rev = "v${version}"; + hash = "sha256-+H3AYe+OWrxxaJ78ofuivz7DB/Fi8voZQyb1p2cCAns="; + }; + + cargoHash = "sha256-ZZz5i415lHWHVBL+Abe5C7gVjwm7/mbJ6I+/mp/96vI="; + + meta = with lib; { + description = "Interpret traceroute output to show names of ASN traversed"; + homepage = src.meta.homepage; + license = [ licenses.mit ]; + maintainers = [ maintainers.berbiche ]; + }; + }); +} diff --git a/profiles/dev/home-manager/default.nix b/profiles/dev/home-manager/default.nix index 539d513..5000200 100644 --- a/profiles/dev/home-manager/default.nix +++ b/profiles/dev/home-manager/default.nix @@ -109,5 +109,8 @@ in # onefetch's libresolv dependency does not build on aarch64 onefetch # neofetch for a git repository : lines of code, repo, etc. + ] ++ lib.filter (lib.myLib.supportedOn pkgs.stdenv.hostPlatform.system) [ + gping + asroute ]; } diff --git a/profiles/dev/home-manager/neovim/default.nix b/profiles/dev/home-manager/neovim/default.nix index 1c0fb07..7a5d185 100644 --- a/profiles/dev/home-manager/neovim/default.nix +++ b/profiles/dev/home-manager/neovim/default.nix @@ -22,11 +22,6 @@ let ''); n = nvim; }; - - supportedOn = platform: pkg: - if pkg.meta ? platforms && pkg.meta ? badPlatforms - then builtins.elem platform pkg.meta.platforms && !builtins.elem platform pkg.meta.badPlatforms - else true; in { imports = [ @@ -38,7 +33,7 @@ in pkgs.fzf pkgs.neovim-remote ] - ++ lib.optional (supportedOn pkgs.stdenv.hostPlatform.system pkgs.neovide) pkgs.neovide; + ++ lib.optional (lib.myLib.supportedOn pkgs.stdenv.hostPlatform.system pkgs.neovide) pkgs.neovide; # programs.neovim.defaultEditor = true; home.sessionVariables = { diff --git a/top-level/lib.nix b/top-level/lib.nix index 8b82c7e..6b3e07c 100644 --- a/top-level/lib.nix +++ b/top-level/lib.nix @@ -25,4 +25,11 @@ lib.extend (libfinal: libprev: { # Returns a list of nix files in the directory without recursing (and without `default.nix`) myLib.nixFilesInDir = directory: libprev.filter (n: libprev.hasSuffix "nix" n && n != "default.nix") (libprev.myLib.filesInDir directory); + + # Returns a boolean indicating whether the the package `pkg` is supported on platform `platform` + # `true`: supported, `false`: unsupported + myLib.supportedOn = platform: pkg: + if pkg.meta ? platforms && pkg.meta ? badPlatforms + then builtins.elem platform pkg.meta.platforms && !builtins.elem platform pkg.meta.badPlatforms + else true; })