summary refs log tree commit diff
path: root/nixos/modules/tasks/network-interfaces-scripted.nix
diff options
context:
space:
mode:
authorrnhmjoj <rnhmjoj@inventati.org>2017-07-28 16:45:58 +0200
committerrnhmjoj <rnhmjoj@inventati.org>2018-02-17 14:01:23 +0100
commitf41111c4da9a7eb5cade95d945eec7576757d27d (patch)
tree4b0616ec89107b10aa06920baf73fde5428b82ce /nixos/modules/tasks/network-interfaces-scripted.nix
parentd00c91c5dab1428941c4ee61e341b01a26f14c90 (diff)
downloadnixlib-f41111c4da9a7eb5cade95d945eec7576757d27d.tar
nixlib-f41111c4da9a7eb5cade95d945eec7576757d27d.tar.gz
nixlib-f41111c4da9a7eb5cade95d945eec7576757d27d.tar.bz2
nixlib-f41111c4da9a7eb5cade95d945eec7576757d27d.tar.lz
nixlib-f41111c4da9a7eb5cade95d945eec7576757d27d.tar.xz
nixlib-f41111c4da9a7eb5cade95d945eec7576757d27d.tar.zst
nixlib-f41111c4da9a7eb5cade95d945eec7576757d27d.zip
nixos/tests: add test for static routes
Diffstat (limited to 'nixos/modules/tasks/network-interfaces-scripted.nix')
-rw-r--r--nixos/modules/tasks/network-interfaces-scripted.nix5
1 files changed, 3 insertions, 2 deletions
diff --git a/nixos/modules/tasks/network-interfaces-scripted.nix b/nixos/modules/tasks/network-interfaces-scripted.nix
index 9dba6d1bd0a2..28bbc27a2693 100644
--- a/nixos/modules/tasks/network-interfaces-scripted.nix
+++ b/nixos/modules/tasks/network-interfaces-scripted.nix
@@ -210,12 +210,13 @@ let
                 ${flip concatMapStrings (i.ipv4Routes ++ i.ipv6Routes) (route:
                   let
                     cidr = "${route.address}/${toString route.prefixLength}";
-                    nextHop = optionalString (route.nextHop != null) ''via "${route.nextHop}"'';
+                    via = optionalString (route.via != null) ''via "${route.via}"'';
+                    options = concatStrings (mapAttrsToList (name: val: "${name} ${val} ") route.options);
                   in
                   ''
                      echo "${cidr}" >> $state
                      echo -n "adding route ${cidr}... "
-                     if out=$(ip route add "${cidr}" ${route.options} ${nextHop} dev "${i.name}" 2>&1); then
+                     if out=$(ip route add "${cidr}" ${options} ${via} dev "${i.name}" 2>&1); then
                        echo "done"
                      elif ! echo "$out" | grep "File exists" >/dev/null 2>&1; then
                        echo "failed"