mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
Merge staging into closure-size
The most complex problems were from dealing with switches reverted in the meantime (gcc5, gmp6, ncurses6). It's likely that darwin is (still) broken nontrivially.
This commit is contained in:
commit
333d69a5f0
1278 changed files with 105731 additions and 30012 deletions
|
@ -174,7 +174,7 @@ in
|
|||
|
||||
# Swap devices.
|
||||
${flip concatMapStrings config.swapDevices (sw:
|
||||
"${sw.device} none swap${prioOption sw.priority}\n"
|
||||
"${sw.realDevice} none swap${prioOption sw.priority}\n"
|
||||
)}
|
||||
'';
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ in
|
|||
serviceConfig.Type = "forking";
|
||||
serviceConfig.ExecStart = ''
|
||||
@${pkgs.nfs-utils}/sbin/rpc.statd rpc.statd --no-notify \
|
||||
${if cfg.statdPort != null then "-p ${toString statdPort}" else ""}
|
||||
${if cfg.statdPort != null then "-p ${toString cfg.statdPort}" else ""}
|
||||
'';
|
||||
serviceConfig.Restart = "always";
|
||||
};
|
||||
|
|
|
@ -4,11 +4,13 @@ with lib;
|
|||
|
||||
let
|
||||
|
||||
makeColor = n: value: "COLOR_${toString n}=${value}";
|
||||
|
||||
vconsoleConf = pkgs.writeText "vconsole.conf"
|
||||
''
|
||||
KEYMAP=${config.i18n.consoleKeyMap}
|
||||
FONT=${config.i18n.consoleFont}
|
||||
'';
|
||||
'' + concatImapStringsSep "\n" makeColor config.i18n.consoleColors;
|
||||
|
||||
in
|
||||
|
||||
|
|
|
@ -222,21 +222,15 @@ in
|
|||
|
||||
createVswitchDevice = n: v: nameValuePair "${n}-netdev"
|
||||
(let
|
||||
managedInterfaces = filter (x: hasAttr x cfg.interfaces) v.interfaces;
|
||||
managedInterfaceServices = concatMap (i: [ "network-addresses-${i}.service" "network-link-${i}.service" ]) managedInterfaces;
|
||||
virtualInterfaces = filter (x: (hasAttr x cfg.interfaces) && cfg.interfaces.${x}.virtual) v.interfaces;
|
||||
virtualInterfaceServices = concatMap (i: [ "${i}-netdev.service" ]) virtualInterfaces;
|
||||
deps = map subsystemDevice v.interfaces;
|
||||
ofRules = pkgs.writeText "vswitch-${n}-openFlowRules" v.openFlowRules;
|
||||
in
|
||||
{ description = "Open vSwitch Interface ${n}";
|
||||
wantedBy = [ "network.target" "vswitchd.service" (subsystemDevice n) ];
|
||||
requires = optionals v.bindInterfaces (deps ++ managedInterfaceServices ++ virtualInterfaceServices);
|
||||
requiredBy = optionals v.bindInterfaces (managedInterfaceServices ++ virtualInterfaceServices);
|
||||
bindsTo = deps ++ [ "vswitchd.service" ];
|
||||
wantedBy = [ "network.target" "vswitchd.service" ] ++ deps;
|
||||
bindsTo = [ "vswitchd.service" (subsystemDevice n) ] ++ deps;
|
||||
partOf = [ "vswitchd.service" ];
|
||||
after = [ "network-pre.target" "vswitchd.service" ] ++ deps ++ managedInterfaceServices ++ virtualInterfaceServices;
|
||||
before = [ "network-interfaces.target" (subsystemDevice n) ];
|
||||
after = [ "network-pre.target" "vswitchd.service" ] ++ deps;
|
||||
before = [ "network-interfaces.target" ];
|
||||
serviceConfig.Type = "oneshot";
|
||||
serviceConfig.RemainAfterExit = true;
|
||||
path = [ pkgs.iproute config.virtualisation.vswitch.package ];
|
||||
|
|
|
@ -426,8 +426,8 @@ in
|
|||
description =
|
||||
''
|
||||
This option allows you to define Open vSwitches that connect
|
||||
physical networks together. The value of this option is an
|
||||
attribute set. Each attribute specifies a vswitch, with the
|
||||
physical networks together. The value of this option is an
|
||||
attribute set. Each attribute specifies a vswitch, with the
|
||||
attribute name specifying the name of the vswitch's network
|
||||
interface.
|
||||
'';
|
||||
|
@ -443,16 +443,6 @@ in
|
|||
"The physical network interfaces connected by the vSwitch.";
|
||||
};
|
||||
|
||||
bindInterfaces = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
If true, then the interfaces of the vSwitch are brought 'up' and especially
|
||||
also 'down' together with the vSwitch. That requires that every interfaces
|
||||
is configured as a systemd network services.
|
||||
'';
|
||||
};
|
||||
|
||||
controllers = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
|
@ -995,21 +985,78 @@ in
|
|||
|
||||
services.udev.packages = mkIf (cfg.wlanInterfaces != {}) [
|
||||
(pkgs.writeTextFile {
|
||||
name = "99-zzz-wlanInterfaces-last.rules";
|
||||
destination = "/etc/udev/rules.d/99-zzz-wlanInterfaces-last.rules";
|
||||
text = ''
|
||||
# If persistent udev device name is not used for an interface, then do not
|
||||
# call systemd for that udev device name and only execute the script that
|
||||
# modifies or prepares the WLAN interfaces. All other commands that would
|
||||
# otherwise be executed when the udev device is added, like, e.g., the calling
|
||||
# of systemd-sysctl or the activation of wpa_supplicant is disabled when the
|
||||
# persistend udev device name is not usef for an interface.
|
||||
${flip (concatMapStringsSep "\n") (attrNames wlanDeviceInterfaces) (device:
|
||||
let script = wlanDeviceUdevScript device (wlanListDeviceFirst device wlanDeviceInterfaces."${device}"); in
|
||||
if hasAttr device cfg.wlanInterfaces
|
||||
then ''ACTION=="add", SUBSYSTEM=="net", NAME=="${device}", ENV{DEVTYPE}=="wlan", RUN+="${script}"''
|
||||
else ''ACTION=="add", SUBSYSTEM=="net", NAME=="${device}", ENV{DEVTYPE}=="wlan", NAME="", TAG-="systemd", RUN:="${script}"'')}
|
||||
'';
|
||||
name = "99-zzz-40-wlanInterfaces.rules";
|
||||
destination = "/etc/udev/rules.d/99-zzz-40-wlanInterfaces.rules";
|
||||
text =
|
||||
let
|
||||
# Collect all interfaces that are defined for a device
|
||||
# as device:interface key:value pairs.
|
||||
wlanDeviceInterfaces =
|
||||
let
|
||||
allDevices = unique (mapAttrsToList (_: v: v.device) cfg.wlanInterfaces);
|
||||
interfacesOfDevice = d: filterAttrs (_: v: v.device == d) cfg.wlanInterfaces;
|
||||
in
|
||||
genAttrs allDevices (d: interfacesOfDevice d);
|
||||
|
||||
# Convert device:interface key:value pairs into a list, and if it exists,
|
||||
# place the interface which is named after the device at the beginning.
|
||||
wlanListDeviceFirst = device: interfaces:
|
||||
if hasAttr device interfaces
|
||||
then mapAttrsToList (n: v: v//{_iName=n;}) (filterAttrs (n: _: n==device) interfaces) ++ mapAttrsToList (n: v: v//{_iName=n;}) (filterAttrs (n: _: n!=device) interfaces)
|
||||
else mapAttrsToList (n: v: v // {_iName = n;}) interfaces;
|
||||
|
||||
# Udev script to execute for the default WLAN interface with the persistend udev name.
|
||||
# The script creates the required, new WLAN interfaces interfaces and configures the
|
||||
# existing, default interface.
|
||||
curInterfaceScript = device: current: new: pkgs.writeScript "udev-run-script-wlan-interfaces-${device}.sh" ''
|
||||
#!${pkgs.stdenv.shell}
|
||||
# Change the wireless phy device to a predictable name.
|
||||
${pkgs.iw}/bin/iw phy `${pkgs.coreutils}/bin/cat /sys/class/net/$INTERFACE/phy80211/name` set name ${device}
|
||||
|
||||
# Add new WLAN interfaces
|
||||
${flip concatMapStrings new (i: ''
|
||||
${pkgs.iw}/bin/iw phy ${device} interface add ${i._iName} type managed
|
||||
'')}
|
||||
|
||||
# Configure the current interface
|
||||
${pkgs.iw}/bin/iw dev ${device} set type ${current.type}
|
||||
${optionalString (current.type == "mesh" && current.meshID!=null) "${pkgs.iw}/bin/iw dev ${device} set meshid ${current.meshID}"}
|
||||
${optionalString (current.type == "monitor" && current.flags!=null) "${pkgs.iw}/bin/iw dev ${device} set monitor ${current.flags}"}
|
||||
${optionalString (current.type == "managed" && current.fourAddr!=null) "${pkgs.iw}/bin/iw dev ${device} set 4addr ${if current.fourAddr then "on" else "off"}"}
|
||||
${optionalString (current.mac != null) "${pkgs.iproute}/bin/ip link set dev ${device} address ${current.mac}"}
|
||||
'';
|
||||
|
||||
# Udev script to execute for a new WLAN interface. The script configures the new WLAN interface.
|
||||
newInterfaceScript = new: pkgs.writeScript "udev-run-script-wlan-interfaces-${new._iName}.sh" ''
|
||||
#!${pkgs.stdenv.shell}
|
||||
# Configure the new interface
|
||||
${pkgs.iw}/bin/iw dev ${new._iName} set type ${new.type}
|
||||
${optionalString (new.type == "mesh" && new.meshID!=null) "${pkgs.iw}/bin/iw dev ${device} set meshid ${new.meshID}"}
|
||||
${optionalString (new.type == "monitor" && new.flags!=null) "${pkgs.iw}/bin/iw dev ${device} set monitor ${new.flags}"}
|
||||
${optionalString (new.type == "managed" && new.fourAddr!=null) "${pkgs.iw}/bin/iw dev ${device} set 4addr ${if new.fourAddr then "on" else "off"}"}
|
||||
${optionalString (new.mac != null) "${pkgs.iproute}/bin/ip link set dev ${device} address ${new.mac}"}
|
||||
'';
|
||||
|
||||
# Udev attributes for systemd to name the device and to create a .device target.
|
||||
systemdAttrs = n: ''NAME:="${n}", ENV{INTERFACE}:="${n}", ENV{SYSTEMD_ALIAS}:="/sys/subsystem/net/devices/${n}", TAG+="systemd"'';
|
||||
in
|
||||
flip (concatMapStringsSep "\n") (attrNames wlanDeviceInterfaces) (device:
|
||||
let
|
||||
interfaces = wlanListDeviceFirst device wlanDeviceInterfaces."${device}";
|
||||
curInterface = elemAt interfaces 0;
|
||||
newInterfaces = drop 1 interfaces;
|
||||
in ''
|
||||
# It is important to have that rule first as overwriting the NAME attribute also prevents the
|
||||
# next rules from matching.
|
||||
${flip (concatMapStringsSep "\n") (wlanListDeviceFirst device wlanDeviceInterfaces."${device}") (interface:
|
||||
''ACTION=="add", SUBSYSTEM=="net", ENV{DEVTYPE}=="wlan", ENV{INTERFACE}=="${interface._iName}", ${systemdAttrs interface._iName}, RUN+="${newInterfaceScript interface}"'')}
|
||||
|
||||
# Add the required, new WLAN interfaces to the default WLAN interface with the
|
||||
# persistent, default name as assigned by udev.
|
||||
ACTION=="add", SUBSYSTEM=="net", ENV{DEVTYPE}=="wlan", NAME=="${device}", ${systemdAttrs curInterface._iName}, RUN+="${curInterfaceScript device curInterface newInterfaces}"
|
||||
# Generate the same systemd events for both 'add' and 'move' udev events.
|
||||
ACTION=="move", SUBSYSTEM=="net", ENV{DEVTYPE}=="wlan", NAME=="${device}", ${systemdAttrs curInterface._iName}
|
||||
'');
|
||||
}) ];
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue