nixos/networking: Fixes

+4 -2
nixos/modules/config/networking.nix
···
ln -s /run/systemd/resolve/resolv.conf /run/resolvconf/interfaces/systemd
''}
-
# Make sure resolv.conf is up to date
-
${pkgs.openresolv}/bin/resolvconf -u
+
# Make sure resolv.conf is up to date if not managed by systemd
+
${optionalString (!config.services.resolved.enable) ''
+
${pkgs.openresolv}/bin/resolvconf -u
+
''}
'';
};
+2 -2
nixos/modules/services/networking/chrony.nix
···
jobs.chronyd =
{ description = "chrony daemon";
-
wantedBy = [ "ip-up.target" ];
-
partOf = [ "ip-up.target" ];
+
wantedBy = [ "multi-user.target" ];
+
after = [ "network.target" ];
path = [ chrony ];
+3 -3
nixos/modules/services/networking/dhcpcd.nix
···
# Don't start dhcpcd on explicitly configured interfaces or on
# interfaces that are part of a bridge, bond or sit device.
ignoredInterfaces =
-
map (i: i.name) (filter (i: if i.useDHCP != null then i.useDHCP else i.ip4 != [ ] || i.ipAddress != null) interfaces)
+
map (i: i.name) (filter (i: if i.useDHCP != null then !i.useDHCP else i.ip4 != [ ] || i.ipAddress != null) interfaces)
++ mapAttrsToList (i: _: i) config.networking.sits
++ concatLists (attrValues (mapAttrs (n: v: v.interfaces) config.networking.bridges))
++ concatLists (attrValues (mapAttrs (n: v: v.interfaces) config.networking.bonds))
···
# If dhcp is disabled but explicit interfaces are enabled,
# we need to provide dhcp just for those interfaces.
allowInterfaces = arrayAppendOrNull cfg.allowInterfaces
-
(if !cfg.useDHCP && enableDHCP then map (i: i.name) (filter (i: i.useDHCP == true) interfaces) else null);
+
(if !config.networking.useDHCP && enableDHCP then
+
map (i: i.name) (filter (i: i.useDHCP == true) interfaces) else null);
# Config file adapted from the one that ships with dhcpcd.
dhcpcdConf = pkgs.writeText "dhcpcd.conf"
···
${config.systemd.package}/bin/systemctl try-restart ntpd.service
${config.systemd.package}/bin/systemctl start ip-up.target
-
${config.systemd.package}/bin/systemctl start network-online.target
fi
#if [ "$reason" = EXPIRE -o "$reason" = RELEASE -o "$reason" = NOCARRIER ] ; then
+1 -2
nixos/modules/services/networking/gogoclient.nix
···
exec ${pkgs.gogoclient}/bin/gogoc -y -f /var/lib/gogoc/gogoc.conf
'';
} // optionalAttrs cfg.autorun {
-
wantedBy = [ "ip-up.target" ];
-
partOf = [ "ip-up.target" ];
+
wantedBy = [ "multi-user.target" ];
};
};
+1 -2
nixos/modules/services/networking/ntpd.nix
···
jobs.ntpd =
{ description = "NTP Daemon";
-
wantedBy = [ "ip-up.target" ];
-
partOf = [ "ip-up.target" ];
+
wantedBy = [ "multi-user.target" ];
path = [ ntp ];
+1 -2
nixos/modules/services/networking/openntpd.nix
···
systemd.services.openntpd = {
description = "OpenNTP Server";
-
wantedBy = [ "ip-up.target" ];
-
partOf = [ "ip-up.target" ];
+
wantedBy = [ "multi-user.target" ];
serviceConfig.ExecStart = "${package}/sbin/ntpd -d -f ${cfgFile}";
};
};
-2
nixos/modules/system/boot/stage-2-init.sh
···
# Use /etc/resolv.conf supplied by systemd-nspawn, if applicable.
if [ -n "@useHostResolvConf@" -a -e /etc/resolv.conf ]; then
cat /etc/resolv.conf | resolvconf -m 1000 -a host
-
else
-
touch /etc/resolv.conf
fi
+2
nixos/modules/system/boot/systemd.nix
···
unitConfig.X-StopOnReconfiguration = true;
};
+
systemd.targets.network-online.after = [ "ip-up.target" ];
+
systemd.units =
mapAttrs' (n: v: nameValuePair "${n}.target" (targetToUnit n v)) cfg.targets
// mapAttrs' (n: v: nameValuePair "${n}.service" (serviceToUnit n v)) cfg.services
+2 -4
nixos/modules/tasks/filesystems/nfs.nix
···
path = [ pkgs.nfsUtils pkgs.sysvtools pkgs.utillinux ];
-
wantedBy = [ "network-online.target" "multi-user.target" ];
-
before = [ "network-online.target" ];
+
wantedBy = [ "multi-user.target" ];
requires = [ "basic.target" "rpcbind.service" ];
after = [ "basic.target" "rpcbind.service" "network.target" ];
···
path = [ pkgs.sysvtools pkgs.utillinux ];
-
wantedBy = [ "network-online.target" "multi-user.target" ];
-
before = [ "network-online.target" ];
+
wantedBy = [ "multi-user.target" ];
requires = [ "rpcbind.service" ];
after = [ "rpcbind.service" ];
+1 -1
nixos/modules/tasks/network-interfaces-scripted.nix
···
after = [ (subsystemDevice i.name) ];
serviceConfig.Type = "oneshot";
serviceConfig.RemainAfterExit = true;
+
path = [ pkgs.iproute ];
script =
''
echo "bringing up interface..."
···
${config.systemd.package}/bin/systemctl try-restart --no-block network-setup.service
fi
${config.systemd.package}/bin/systemctl start ip-up.target
-
${config.systemd.package}/bin/systemctl start network-online.target
'';
preStop =
''
+3 -3
nixos/modules/tasks/network-interfaces.nix
···
pkgs.iw
pkgs.rfkill
pkgs.openresolv
-
]
+
];
systemd.services = {
network-local-commands = {
description = "Extra networking commands.";
-
before = [ "network.target" "network-online.target" ];
-
wantedBy = [ "network.target" "network-online.target" ];
+
before = [ "network.target" ];
+
wantedBy = [ "network.target" ];
unitConfig.ConditionCapability = "CAP_NET_ADMIN";
path = [ pkgs.iproute ];
serviceConfig.Type = "oneshot";