1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-10 14:50:40 +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
attrValues
concatLists
concatStringsSep
flip
init
length
listToAttrs
mapAttrsToList
mkDefault
@ -17,7 +20,15 @@
mkMerge
nameValuePair
optional
splitString
;
removeCidrMask = x: let
toks = splitString "/" x;
in
if length toks > 1
then concatStringsSep "/" (init toks)
else builtins.head toks;
in {
options.topology.extractors.systemd-network.enable = mkEnableOption "topology systemd-network extractor" // {default = true;};
@ -60,8 +71,7 @@ in {
optional (interfaceName != null) {
${interfaceName} = {
mac = network.matchConfig.MACAddress or null;
# TODO: FIXME: remove cidr mask
addresses = network.address ++ (network.networkConfig.Address or []);
addresses = map removeCidrMask (network.address ++ (network.networkConfig.Address or []));
gateways = network.gateway ++ (network.networkConfig.Gateway or []);
};
}