From 9490822c1a539669d1db951cc4807bcad19d3832 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Mon, 9 Dec 2024 00:43:45 +0100 Subject: [PATCH] feat: introduce iproute2 module for linkage In the future, we will make it possible to choose between iproute2 and busybox more properly. Signed-off-by: Raito Bezarius --- lib/eval-config.nix | 1 + modules/all-modules.nix | 3 ++- modules/iproute2.nix | 28 ++++++++++++++++++++++++++++ overlay.nix | 4 ++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 modules/iproute2.nix diff --git a/lib/eval-config.nix b/lib/eval-config.nix index 4c3c009..a940497 100644 --- a/lib/eval-config.nix +++ b/lib/eval-config.nix @@ -12,6 +12,7 @@ in "${modulesPath}/hardware.nix" "${modulesPath}/base.nix" "${modulesPath}/busybox.nix" + "${modulesPath}/iproute2.nix" "${modulesPath}/hostname.nix" "${modulesPath}/kernel" "${modulesPath}/s6" diff --git a/modules/all-modules.nix b/modules/all-modules.nix index 98352c1..9afff7d 100644 --- a/modules/all-modules.nix +++ b/modules/all-modules.nix @@ -4,9 +4,10 @@ { imports = [ - ./base.nix + ./base.nix ./bridge ./busybox.nix + ./iproute2.nix ./dhcp6c ./jitter-rng ./dnsmasq diff --git a/modules/iproute2.nix b/modules/iproute2.nix new file mode 100644 index 0000000..2555d44 --- /dev/null +++ b/modules/iproute2.nix @@ -0,0 +1,28 @@ +{ config, pkgs, lib, ... }: +let + inherit (lib) mkEnableOption mkPackageOption mkIf genAttrs; + inherit (pkgs.pseudofile) dir symlink; + cfg = config.programs.iproute2; + minimalPrograms = [ + "ip" + "devlink" + "ss" + "bridge" + "genl" + "ifstat" + "nstat" + ]; + links = genAttrs minimalPrograms (p: symlink "${cfg.package}/bin/${p}"); +in +{ + options.programs.iproute2 = { + enable = mkEnableOption "the iproute2 programs instead of busybox variants"; + package = mkPackageOption pkgs "iproute2" { }; + }; + + config = mkIf cfg.enable { + filesystem = dir { + bin = dir links; + }; + }; +} diff --git a/overlay.nix b/overlay.nix index b170c24..fda6239 100644 --- a/overlay.nix +++ b/overlay.nix @@ -210,6 +210,10 @@ extraPkgs // { echo "Removing unnecessary binary $out/sbin/$needless_binary" rm "$out/sbin/$needless_binary" done + # No man + rm -rf "$out/share" + # Remove all the data about distributions for tc. + rm -rf "$out/lib" ''; }); # Don't bring ebpf stuff to the table.