···2471 hosts.
2472 </para>
2473 </listitem>
2474+ <listitem>
2475+ <para>
2476+ The option
2477+ <link xlink:href="options.html#opt-networking.useDHCP">networking.useDHCP</link>
2478+ isn’t deprecated anymore. When using
2479+ <link xlink:href="options.html#opt-networking.useNetworkd"><literal>systemd-networkd</literal></link>,
2480+ a generic <literal>.network</literal>-unit is added which
2481+ enables DHCP for each interface matching
2482+ <literal>en*</literal>, <literal>eth*</literal> or
2483+ <literal>wl*</literal> with priority 99 (which means that it
2484+ doesn’t have any effect if such an interface is matched by a
2485+ <literal>.network-</literal>unit with a lower priority). In
2486+ case of scripted networking, no behavior was changed.
2487+ </para>
2488+ </listitem>
2489 </itemizedlist>
2490 </section>
2491</section>
+7
nixos/doc/manual/release-notes/rl-2205.section.md
···877 `true` starting with NixOS 22.11. Enable it explicitly if you need to control
878 Snapserver remotely or connect streamig clients from other hosts.
8790000000880<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
···877 `true` starting with NixOS 22.11. Enable it explicitly if you need to control
878 Snapserver remotely or connect streamig clients from other hosts.
879880+- The option [networking.useDHCP](options.html#opt-networking.useDHCP) isn't deprecated anymore.
881+ When using [`systemd-networkd`](options.html#opt-networking.useNetworkd), a generic
882+ `.network`-unit is added which enables DHCP for each interface matching `en*`, `eth*`
883+ or `wl*` with priority 99 (which means that it doesn't have any effect if such an interface is matched
884+ by a `.network-`unit with a lower priority). In case of scripted networking, no behavior
885+ was changed.
886+887<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
···581EOF
582583sub generateNetworkingDhcpConfig {
0584 my $config = <<EOF;
585- # The global useDHCP flag is deprecated, therefore explicitly set to false here.
586- # Per-interface useDHCP will be mandatory in the future, so this generated config
587- # replicates the default behaviour.
588- networking.useDHCP = lib.mkDefault false;
0589EOF
590591 foreach my $path (glob "/sys/class/net/*") {
592 my $dev = basename($path);
593 if ($dev ne "lo") {
594- $config .= " networking.interfaces.$dev.useDHCP = lib.mkDefault true;\n";
595 }
596 }
597
···581EOF
582583sub generateNetworkingDhcpConfig {
584+ # FIXME disable networking.useDHCP by default when switching to networkd.
585 my $config = <<EOF;
586+ # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
587+ # (the default) this is the recommended approach. When using systemd-networkd it's
588+ # still possible to use this option, but it's recommended to use it in conjunction
589+ # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
590+ networking.useDHCP = lib.mkDefault true;
591EOF
592593 foreach my $path (glob "/sys/class/net/*") {
594 my $dev = basename($path);
595 if ($dev ne "lo") {
596+ $config .= " # networking.interfaces.$dev.useDHCP = lib.mkDefault true;\n";
597 }
598 }
599
+14-1
nixos/modules/services/games/factorio.nix
···87 a new map with default settings will be generated before starting the service.
88 '';
89 };
00000000000090 # TODO Add more individual settings as nixos-options?
91 # TODO XXX The server tries to copy a newly created config file over the old one
92 # on shutdown, but fails, because it's in the nix store. When is this needed?
···250 "--config=${cfg.configFile}"
251 "--port=${toString cfg.port}"
252 "--bind=${cfg.bind}"
253- "--start-server=${mkSavePath cfg.saveName}"
254 "--server-settings=${serverSettingsFile}"
0255 (optionalString (cfg.mods != []) "--mod-directory=${modDir}")
256 (optionalString (cfg.admins != []) "--server-adminlist=${serverAdminsFile}")
257 ];
···87 a new map with default settings will be generated before starting the service.
88 '';
89 };
90+ loadLatestSave = mkOption {
91+ type = types.bool;
92+ default = false;
93+ description = ''
94+ Load the latest savegame on startup. This overrides saveName, in that the latest
95+ save will always be used even if a saved game of the given name exists. It still
96+ controls the 'canonical' name of the savegame.
97+98+ Set this to true to have the server automatically reload a recent autosave after
99+ a crash or desync.
100+ '';
101+ };
102 # TODO Add more individual settings as nixos-options?
103 # TODO XXX The server tries to copy a newly created config file over the old one
104 # on shutdown, but fails, because it's in the nix store. When is this needed?
···262 "--config=${cfg.configFile}"
263 "--port=${toString cfg.port}"
264 "--bind=${cfg.bind}"
265+ (optionalString (!cfg.loadLatestSave) "--start-server=${mkSavePath cfg.saveName}")
266 "--server-settings=${serverSettingsFile}"
267+ (optionalString cfg.loadLatestSave "--start-server-load-latest")
268 (optionalString (cfg.mods != []) "--mod-directory=${modDir}")
269 (optionalString (cfg.admins != []) "--server-adminlist=${serverAdminsFile}")
270 ];
···43 } {
44 assertion = cfg.defaultGateway6 == null || cfg.defaultGateway6.interface == null;
45 message = "networking.defaultGateway6.interface is not supported by networkd.";
46- } {
47- assertion = cfg.useDHCP == false;
48- message = ''
49- networking.useDHCP is not supported by networkd.
50- Please use per interface configuration and set the global option to false.
51- '';
52 } ] ++ flip mapAttrsToList cfg.bridges (n: { rstp, ... }: {
53 assertion = !rstp;
54 message = "networking.bridges.${n}.rstp is not supported by networkd.";
···80 in mkMerge [ {
81 enable = true;
82 }
00000000000000000000000000000000000083 (mkMerge (forEach interfaces (i: {
84 netdevs = mkIf i.virtual ({
85 "40-${i.name}" = {
···43 } {
44 assertion = cfg.defaultGateway6 == null || cfg.defaultGateway6.interface == null;
45 message = "networking.defaultGateway6.interface is not supported by networkd.";
00000046 } ] ++ flip mapAttrsToList cfg.bridges (n: { rstp, ... }: {
47 assertion = !rstp;
48 message = "networking.bridges.${n}.rstp is not supported by networkd.";
···74 in mkMerge [ {
75 enable = true;
76 }
77+ (mkIf cfg.useDHCP {
78+ networks."99-ethernet-default-dhcp" = lib.mkIf cfg.useDHCP {
79+ # We want to match physical ethernet interfaces as commonly
80+ # found on laptops, desktops and servers, to provide an
81+ # "out-of-the-box" setup that works for common cases. This
82+ # heuristic isn't perfect (it could match interfaces with
83+ # custom names that _happen_ to start with en or eth), but
84+ # should be good enough to make the common case easy and can
85+ # be overridden on a case-by-case basis using
86+ # higher-priority networks or by disabling useDHCP.
87+88+ # Type=ether matches veth interfaces as well, and this is
89+ # more likely to result in interfaces being configured to
90+ # use DHCP when they shouldn't.
91+92+ # We set RequiredForOnline to false, because it's fairly
93+ # common for such devices to have multiple interfaces and
94+ # only one of them to be connected (e.g. a laptop with
95+ # ethernet and WiFi interfaces). Maybe one day networkd will
96+ # support "any"-style RequiredForOnline...
97+ matchConfig.Name = ["en*" "eth*"];
98+ DHCP = "yes";
99+ linkConfig.RequiredForOnline = lib.mkDefault false;
100+ };
101+ networks."99-wireless-client-dhcp" = lib.mkIf cfg.useDHCP {
102+ # Like above, but this is much more likely to be correct.
103+ matchConfig.WLANInterfaceType = "station";
104+ DHCP = "yes";
105+ linkConfig.RequiredForOnline = lib.mkDefault false;
106+ # We also set the route metric to one more than the default
107+ # of 1024, so that Ethernet is preferred if both are
108+ # available.
109+ dhcpV4Config.RouteMetric = 1025;
110+ ipv6AcceptRAConfig.RouteMetric = 1025;
111+ };
112+ })
113 (mkMerge (forEach interfaces (i: {
114 netdevs = mkIf i.virtual ({
115 "40-${i.name}" = {
-5
nixos/modules/tasks/network-interfaces.nix
···1254 Whether to use DHCP to obtain an IP address and other
1255 configuration for all network interfaces that are not manually
1256 configured.
1257-1258- Using this option is highly discouraged and also incompatible with
1259- <option>networking.useNetworkd</option>. Please use
1260- <option>networking.interfaces.<name>.useDHCP</option> instead
1261- and set this to false.
1262 '';
1263 };
1264
···1254 Whether to use DHCP to obtain an IP address and other
1255 configuration for all network interfaces that are not manually
1256 configured.
000001257 '';
1258 };
1259