From ea133ded213256558dcf7936528c55f1a69c301d Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 3 Mar 2026 09:33:11 -0500 Subject: [PATCH] Add the next_hop script. This script determines the next hop for a packet leaving this machine destined for the given address. --- nix/configuration/roles/network/default.nix | 9 +++++++++ .../roles/network/files/next_hop_linux.bash | 7 +++++++ 2 files changed, 16 insertions(+) create mode 100644 nix/configuration/roles/network/files/next_hop_linux.bash diff --git a/nix/configuration/roles/network/default.nix b/nix/configuration/roles/network/default.nix index 27845a47..62f3ed82 100644 --- a/nix/configuration/roles/network/default.nix +++ b/nix/configuration/roles/network/default.nix @@ -15,6 +15,14 @@ # "2001:4860:4860::8844#dns.google" # "2001:4860:4860::8888#dns.google" +let + patchScriptBin = + filename: contents: + ((pkgs.writeScriptBin filename contents).overrideAttrs (old: { + buildCommand = "${old.buildCommand}\n patchShebangs $out"; + })); + next_hop = (patchScriptBin "next_hop" (builtins.readFile ./files/next_hop_linux.bash)); +in { imports = [ ]; @@ -88,6 +96,7 @@ arp-scan # To find devices on the network wavemon dhcpcd # For Android USB tethering. + next_hop ]; boot.extraModprobeConfig = '' diff --git a/nix/configuration/roles/network/files/next_hop_linux.bash b/nix/configuration/roles/network/files/next_hop_linux.bash new file mode 100644 index 00000000..4b72c84e --- /dev/null +++ b/nix/configuration/roles/network/files/next_hop_linux.bash @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# +set -euo pipefail +IFS=$'\n\t' +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +exec ip route get "${@}"