1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-10 23:00:39 +02:00

feat(topology): remove cidr mask from systemd network addresses

This commit is contained in:
oddlama 2024-04-01 14:33:50 +02:00
parent 30579a433e
commit 35643676b4
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A

View file

@ -8,7 +8,10 @@
any any
attrValues attrValues
concatLists concatLists
concatStringsSep
flip flip
init
length
listToAttrs listToAttrs
mapAttrsToList mapAttrsToList
mkDefault mkDefault
@ -17,7 +20,15 @@
mkMerge mkMerge
nameValuePair nameValuePair
optional optional
splitString
; ;
removeCidrMask = x: let
toks = splitString "/" x;
in
if length toks > 1
then concatStringsSep "/" (init toks)
else builtins.head toks;
in { in {
options.topology.extractors.systemd-network.enable = mkEnableOption "topology systemd-network extractor" // {default = true;}; options.topology.extractors.systemd-network.enable = mkEnableOption "topology systemd-network extractor" // {default = true;};
@ -60,8 +71,7 @@ in {
optional (interfaceName != null) { optional (interfaceName != null) {
${interfaceName} = { ${interfaceName} = {
mac = network.matchConfig.MACAddress or null; mac = network.matchConfig.MACAddress or null;
# TODO: FIXME: remove cidr mask addresses = map removeCidrMask (network.address ++ (network.networkConfig.Address or []));
addresses = network.address ++ (network.networkConfig.Address or []);
gateways = network.gateway ++ (network.networkConfig.Gateway or []); gateways = network.gateway ++ (network.networkConfig.Gateway or []);
}; };
} }