diff options
author | Linus Heckemann <git@sphalerite.org> | 2024-05-23 17:46:15 +0200 |
---|---|---|
committer | Linus Heckemann <git@sphalerite.org> | 2024-05-23 17:46:15 +0200 |
commit | cf50bd0aa1a0d9271fd0c547f435b5c9a2a0f2c0 (patch) | |
tree | 69dc5d86513721ab8594b33451b7c54c0e4c2f35 /nixos/modules/tasks | |
parent | f9f943b36eb1f9f13b23a177fc6f8bc40071534b (diff) | |
download | nixlib-cf50bd0aa1a0d9271fd0c547f435b5c9a2a0f2c0.tar nixlib-cf50bd0aa1a0d9271fd0c547f435b5c9a2a0f2c0.tar.gz nixlib-cf50bd0aa1a0d9271fd0c547f435b5c9a2a0f2c0.tar.bz2 nixlib-cf50bd0aa1a0d9271fd0c547f435b5c9a2a0f2c0.tar.lz nixlib-cf50bd0aa1a0d9271fd0c547f435b5c9a2a0f2c0.tar.xz nixlib-cf50bd0aa1a0d9271fd0c547f435b5c9a2a0f2c0.tar.zst nixlib-cf50bd0aa1a0d9271fd0c547f435b5c9a2a0f2c0.zip |
nixos/networking: use mkIfs on the inner attributes
This is a bit more compact and yields the same evaluation results.
Diffstat (limited to 'nixos/modules/tasks')
-rw-r--r-- | nixos/modules/tasks/network-interfaces-systemd.nix | 76 |
1 files changed, 20 insertions, 56 deletions
diff --git a/nixos/modules/tasks/network-interfaces-systemd.nix b/nixos/modules/tasks/network-interfaces-systemd.nix index c1241d11de87..d30ed3069f55 100644 --- a/nixos/modules/tasks/network-interfaces-systemd.nix +++ b/nixos/modules/tasks/network-interfaces-systemd.nix @@ -95,64 +95,28 @@ let address = forEach (interfaceIps i) (ip: "${ip.address}/${toString ip.prefixLength}"); routes = forEach (interfaceRoutes i) - (route: mkMerge [ + (route: { # Most of these route options have not been tested. # Please fix or report any mistakes you may find. - (mkIf (route.address != null && route.prefixLength != null) { - Destination = "${route.address}/${toString route.prefixLength}"; - }) - (mkIf (route.options ? fastopen_no_cookie) { - FastOpenNoCookie = route.options.fastopen_no_cookie; - }) - (mkIf (route.via != null) { - Gateway = route.via; - }) - (mkIf (route.type != null) { - Type = route.type; - }) - (mkIf (route.options ? onlink) { - GatewayOnLink = true; - }) - (mkIf (route.options ? initrwnd) { - InitialAdvertisedReceiveWindow = route.options.initrwnd; - }) - (mkIf (route.options ? initcwnd) { - InitialCongestionWindow = route.options.initcwnd; - }) - (mkIf (route.options ? pref) { - IPv6Preference = route.options.pref; - }) - (mkIf (route.options ? mtu) { - MTUBytes = route.options.mtu; - }) - (mkIf (route.options ? metric) { - Metric = route.options.metric; - }) - (mkIf (route.options ? src) { - PreferredSource = route.options.src; - }) - (mkIf (route.options ? protocol) { - Protocol = route.options.protocol; - }) - (mkIf (route.options ? quickack) { - QuickAck = route.options.quickack; - }) - (mkIf (route.options ? scope) { - Scope = route.options.scope; - }) - (mkIf (route.options ? from) { - Source = route.options.from; - }) - (mkIf (route.options ? table) { - Table = route.options.table; - }) - (mkIf (route.options ? advmss) { - TCPAdvertisedMaximumSegmentSize = route.options.advmss; - }) - (mkIf (route.options ? ttl-propagate) { - TTLPropagate = route.options.ttl-propagate == "enabled"; - }) - ]); + Destination = mkIf (route.address != null && route.prefixLength != null) "${route.address}/${toString route.prefixLength}"; + FastOpenNoCookie = mkIf (route.options ? fastopen_no_cookie) route.options.fastopen_no_cookie; + Gateway = mkIf (route.via != null) route.via; + Type = mkIf (route.type != null) route.type; + GatewayOnLink = mkIf (route.options ? onlink) true; + InitialAdvertisedReceiveWindow = mkIf (route.options ? initrwnd) route.options.initrwnd; + InitialCongestionWindow = mkIf (route.options ? initcwnd) route.options.initcwnd; + IPv6Preference = mkIf (route.options ? pref) route.options.pref; + MTUBytes = mkIf (route.options ? mtu) route.options.mtu; + Metric = mkIf (route.options ? metric) route.options.metric; + PreferredSource = mkIf (route.options ? src) route.options.src; + Protocol = mkIf (route.options ? protocol) route.options.protocol; + QuickAck = mkIf (route.options ? quickack) route.options.quickack; + Scope = mkIf (route.options ? scope) route.options.scope; + Source = mkIf (route.options ? from) route.options.from; + Table = mkIf (route.options ? table) route.options.table; + TCPAdvertisedMaximumSegmentSize = mkIf (route.options ? advmss) route.options.advmss; + TTLPropagate = mkIf (route.options ? ttl-propagate) route.options.ttl-propagate == "enabled"; + }); networkConfig.IPv6PrivacyExtensions = "kernel"; linkConfig = optionalAttrs (i.macAddress != null) { MACAddress = i.macAddress; |