git.iko.soy/typeable/nixpkgs
on master help sign in
network-interfaces service: add metric option for defaultGateways
commit3fd44e2912795db39ad9c5c9bb977663a4d129c7 authorFranz Pletz <fpletz@fnordicwalking.de> dateThu 9 Feb 2017, 23:09 (10 years ago) parent9973f49
2 files changed+14−3
nixos/modules/tasks/network-interfaces-scripted.nix+7−3 nixos/modules/tasks/network-interfaces.nix+7
nixos/modules/tasks/network-interfaces-scripted.nix+7−3
@@ -104,15 +104,19 @@ in
104104 # Set the default gateway.
105105 ${optionalString (cfg.defaultGateway != null && cfg.defaultGateway.address != "") ''
106106 # FIXME: get rid of "|| true" (necessary to make it idempotent).
107− ip route add default via "${cfg.defaultGateway.address}" ${
107+ ip route add default ${optionalString (cfg.defaultGateway.metric != null)
108+ "metric ${toString cfg.defaultGateway.metric}"
109+ } via "${cfg.defaultGateway.address}" ${
108110 optionalString (cfg.defaultGatewayWindowSize != null)
109111 "window ${toString cfg.defaultGatewayWindowSize}"} ${
110112 optionalString (cfg.defaultGateway.interface != null)
111− "dev ${cfg.defaultGateway.interface}"}|| true
113+ "dev ${cfg.defaultGateway.interface}"} || true
112114 ''}
113115 ${optionalString (cfg.defaultGateway6 != null && cfg.defaultGateway6.address != "") ''
114116 # FIXME: get rid of "|| true" (necessary to make it idempotent).
115− ip -6 route add ::/0 via "${cfg.defaultGateway6.address}" ${
117+ ip -6 route add ::/0 ${optionalString (cfg.defaultGateway6.metric != null)
118+ "metric ${toString cfg.defaultGateway6.metric}"
119+ } via "${cfg.defaultGateway6.address}" ${
116120 optionalString (cfg.defaultGatewayWindowSize != null)
117121 "window ${toString cfg.defaultGatewayWindowSize}"} ${
118122 optionalString (cfg.defaultGateway6.interface != null)
nixos/modules/tasks/network-interfaces.nix+7
@@ -134,6 +134,13 @@ let
134134 description = "The default gateway interface.";
135135 };
136136
137+ metric = mkOption {
138+ type = types.nullOr types.int;
139+ default = null;
140+ example = 42;
141+ description = "The default gateway metric/preference.";
142+ };
143+
137144 };
138145
139146 };