···2858 })
2859 ];
2860000000000002861 stage1Config = let
2862 cfg = config.boot.initrd.systemd.network;
2863 in mkMerge [
···2921 ];
2922 kernelModules = [ "af_packet" ];
29232924- systemd.services.nixos-flush-networkd = mkIf config.boot.initrd.network.flushBeforeStage2 {
2925- description = "Flush Network Configuration";
2926- wantedBy = ["initrd.target"];
2927- after = ["systemd-networkd.service" "dbus.socket" "dbus.service"];
2928- before = ["shutdown.target" "initrd-switch-root.target"];
2929- conflicts = ["shutdown.target" "initrd-switch-root.target"];
2930- unitConfig.DefaultDependencies = false;
2931- serviceConfig = {
2932- # This service does nothing when starting, but brings down
2933- # interfaces when switching root. This is the easiest way to
2934- # ensure proper ordering while stopping. See systemd.unit(5)
2935- # section on Before= and After=. The important part is that
2936- # we are stopped before units we need, like dbus.service,
2937- # and that we are stopped before starting units like
2938- # initrd-switch-root.target
2939- Type = "oneshot";
2940- RemainAfterExit = true;
2941- ExecStart = "/bin/true";
2942- };
2943- # systemd-networkd doesn't bring down interfaces on its own
2944- # when it exits (see: systemd-networkd(8)), so we have to do
2945- # it ourselves. The networkctl command doesn't have a way to
2946- # bring all interfaces down, so we have to iterate over the
2947- # list and filter out unmanaged interfaces to bring them down
2948- # individually.
2949- preStop = ''
2950- networkctl list --full --no-legend | while read _idx link _type _operational setup _; do
2951- [ "$setup" = unmanaged ] && continue
2952- networkctl down "$link"
2953- done
2954- '';
2955- };
2956-2957 })
2958 ];
29592960in
29612962{
002963 options = {
2964 systemd.network = commonOptions true;
2965 boot.initrd.systemd.network = commonOptions "shallow";