nixos/networkd: Add routes from interfaces to [Route] section of .network file #93635
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation for this change
Similarly to my motivation for #93598, I want to improve consistency between when
networking.useNetworkd
istrue
and when it'sfalse
. In particular I want to be able to write a NixOS module that can abstract out a non-trivial networking setup but still be agnostic to whether the system uses networkd or not.Currently any routes that are set in
networking.interfaces.<interface>.routes
are completely ignored when using networkd. This commit instead adds them to thesystemd.network.networks.<network>.routes
option of the corresponding networkd network.One thing that's tricky is that there isn't a trivial mapping between the options in
networking.interfaces.<interface>.routes
, which allows you to specifyinterface
,via
andoptions
(the latter is passed more or less directly to theip route
command) andsystemd.network
's[Route]
options. I've not attempted to do this in a complete way, but I do look at some of theoptions
attributes and try to do the most sensible thing with them. I chose the particular options I did simply because they were useful to me. The "proper" way to do this would probably be to move them to be top level options ofnetworking.interfaces.<interface>.routes
rather than untyped strings in theoptions
attrset..Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)