nixos/networking: Fixes

This commit is contained in:
William A. Kennington III 2014-11-26 11:19:31 -08:00
parent 4f2a041345
commit 1860ee27b0
11 changed files with 20 additions and 23 deletions

View File

@ -112,8 +112,10 @@ in
ln -s /run/systemd/resolve/resolv.conf /run/resolvconf/interfaces/systemd ln -s /run/systemd/resolve/resolv.conf /run/resolvconf/interfaces/systemd
''} ''}
# Make sure resolv.conf is up to date # Make sure resolv.conf is up to date if not managed by systemd
${optionalString (!config.services.resolved.enable) ''
${pkgs.openresolv}/bin/resolvconf -u ${pkgs.openresolv}/bin/resolvconf -u
''}
''; '';
}; };

View File

@ -99,8 +99,8 @@ in
jobs.chronyd = jobs.chronyd =
{ description = "chrony daemon"; { description = "chrony daemon";
wantedBy = [ "ip-up.target" ]; wantedBy = [ "multi-user.target" ];
partOf = [ "ip-up.target" ]; after = [ "network.target" ];
path = [ chrony ]; path = [ chrony ];

View File

@ -15,7 +15,7 @@ let
# Don't start dhcpcd on explicitly configured interfaces or on # Don't start dhcpcd on explicitly configured interfaces or on
# interfaces that are part of a bridge, bond or sit device. # interfaces that are part of a bridge, bond or sit device.
ignoredInterfaces = 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 ++ 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.bridges))
++ concatLists (attrValues (mapAttrs (n: v: v.interfaces) config.networking.bonds)) ++ concatLists (attrValues (mapAttrs (n: v: v.interfaces) config.networking.bonds))
@ -28,7 +28,8 @@ let
# If dhcp is disabled but explicit interfaces are enabled, # If dhcp is disabled but explicit interfaces are enabled,
# we need to provide dhcp just for those interfaces. # we need to provide dhcp just for those interfaces.
allowInterfaces = arrayAppendOrNull cfg.allowInterfaces 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. # Config file adapted from the one that ships with dhcpcd.
dhcpcdConf = pkgs.writeText "dhcpcd.conf" dhcpcdConf = pkgs.writeText "dhcpcd.conf"
@ -71,7 +72,6 @@ let
${config.systemd.package}/bin/systemctl try-restart ntpd.service ${config.systemd.package}/bin/systemctl try-restart ntpd.service
${config.systemd.package}/bin/systemctl start ip-up.target ${config.systemd.package}/bin/systemctl start ip-up.target
${config.systemd.package}/bin/systemctl start network-online.target
fi fi
#if [ "$reason" = EXPIRE -o "$reason" = RELEASE -o "$reason" = NOCARRIER ] ; then #if [ "$reason" = EXPIRE -o "$reason" = RELEASE -o "$reason" = NOCARRIER ] ; then

View File

@ -76,8 +76,7 @@ in
exec ${pkgs.gogoclient}/bin/gogoc -y -f /var/lib/gogoc/gogoc.conf exec ${pkgs.gogoclient}/bin/gogoc -y -f /var/lib/gogoc/gogoc.conf
''; '';
} // optionalAttrs cfg.autorun { } // optionalAttrs cfg.autorun {
wantedBy = [ "ip-up.target" ]; wantedBy = [ "multi-user.target" ];
partOf = [ "ip-up.target" ];
}; };
}; };

View File

@ -76,8 +76,7 @@ in
jobs.ntpd = jobs.ntpd =
{ description = "NTP Daemon"; { description = "NTP Daemon";
wantedBy = [ "ip-up.target" ]; wantedBy = [ "multi-user.target" ];
partOf = [ "ip-up.target" ];
path = [ ntp ]; path = [ ntp ];

View File

@ -41,8 +41,7 @@ in
systemd.services.openntpd = { systemd.services.openntpd = {
description = "OpenNTP Server"; description = "OpenNTP Server";
wantedBy = [ "ip-up.target" ]; wantedBy = [ "multi-user.target" ];
partOf = [ "ip-up.target" ];
serviceConfig.ExecStart = "${package}/sbin/ntpd -d -f ${cfgFile}"; serviceConfig.ExecStart = "${package}/sbin/ntpd -d -f ${cfgFile}";
}; };
}; };

View File

@ -141,8 +141,6 @@ fi
# Use /etc/resolv.conf supplied by systemd-nspawn, if applicable. # Use /etc/resolv.conf supplied by systemd-nspawn, if applicable.
if [ -n "@useHostResolvConf@" -a -e /etc/resolv.conf ]; then if [ -n "@useHostResolvConf@" -a -e /etc/resolv.conf ]; then
cat /etc/resolv.conf | resolvconf -m 1000 -a host cat /etc/resolv.conf | resolvconf -m 1000 -a host
else
touch /etc/resolv.conf
fi fi

View File

@ -945,6 +945,8 @@ in
unitConfig.X-StopOnReconfiguration = true; unitConfig.X-StopOnReconfiguration = true;
}; };
systemd.targets.network-online.after = [ "ip-up.target" ];
systemd.units = systemd.units =
mapAttrs' (n: v: nameValuePair "${n}.target" (targetToUnit n v)) cfg.targets mapAttrs' (n: v: nameValuePair "${n}.target" (targetToUnit n v)) cfg.targets
// mapAttrs' (n: v: nameValuePair "${n}.service" (serviceToUnit n v)) cfg.services // mapAttrs' (n: v: nameValuePair "${n}.service" (serviceToUnit n v)) cfg.services

View File

@ -73,8 +73,7 @@ in
path = [ pkgs.nfsUtils pkgs.sysvtools pkgs.utillinux ]; path = [ pkgs.nfsUtils pkgs.sysvtools pkgs.utillinux ];
wantedBy = [ "network-online.target" "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
before = [ "network-online.target" ];
requires = [ "basic.target" "rpcbind.service" ]; requires = [ "basic.target" "rpcbind.service" ];
after = [ "basic.target" "rpcbind.service" "network.target" ]; after = [ "basic.target" "rpcbind.service" "network.target" ];
@ -100,8 +99,7 @@ in
path = [ pkgs.sysvtools pkgs.utillinux ]; path = [ pkgs.sysvtools pkgs.utillinux ];
wantedBy = [ "network-online.target" "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
before = [ "network-online.target" ];
requires = [ "rpcbind.service" ]; requires = [ "rpcbind.service" ];
after = [ "rpcbind.service" ]; after = [ "rpcbind.service" ];

View File

@ -114,6 +114,7 @@ in
after = [ (subsystemDevice i.name) ]; after = [ (subsystemDevice i.name) ];
serviceConfig.Type = "oneshot"; serviceConfig.Type = "oneshot";
serviceConfig.RemainAfterExit = true; serviceConfig.RemainAfterExit = true;
path = [ pkgs.iproute ];
script = script =
'' ''
echo "bringing up interface..." echo "bringing up interface..."
@ -142,7 +143,6 @@ in
${config.systemd.package}/bin/systemctl try-restart --no-block network-setup.service ${config.systemd.package}/bin/systemctl try-restart --no-block network-setup.service
fi fi
${config.systemd.package}/bin/systemctl start ip-up.target ${config.systemd.package}/bin/systemctl start ip-up.target
${config.systemd.package}/bin/systemctl start network-online.target
''; '';
preStop = preStop =
'' ''

View File

@ -624,13 +624,13 @@ in
pkgs.iw pkgs.iw
pkgs.rfkill pkgs.rfkill
pkgs.openresolv pkgs.openresolv
] ];
systemd.services = { systemd.services = {
network-local-commands = { network-local-commands = {
description = "Extra networking commands."; description = "Extra networking commands.";
before = [ "network.target" "network-online.target" ]; before = [ "network.target" ];
wantedBy = [ "network.target" "network-online.target" ]; wantedBy = [ "network.target" ];
unitConfig.ConditionCapability = "CAP_NET_ADMIN"; unitConfig.ConditionCapability = "CAP_NET_ADMIN";
path = [ pkgs.iproute ]; path = [ pkgs.iproute ];
serviceConfig.Type = "oneshot"; serviceConfig.Type = "oneshot";