2014-04-14 16:26:48 +02:00
|
|
|
|
{ config, lib, pkgs, ... }:
|
2012-03-15 08:19:17 +01:00
|
|
|
|
|
2013-01-03 18:55:56 +01:00
|
|
|
|
with pkgs;
|
2014-05-05 20:58:51 +02:00
|
|
|
|
with lib;
|
2012-03-15 08:19:17 +01:00
|
|
|
|
|
|
|
|
|
let
|
2012-09-19 14:13:34 +02:00
|
|
|
|
cfg = config.networking.networkmanager;
|
|
|
|
|
|
2018-07-05 23:22:09 +02:00
|
|
|
|
dynamicHostsEnabled =
|
|
|
|
|
cfg.dynamicHosts.enable && cfg.dynamicHosts.hostsDirs != {};
|
|
|
|
|
|
2015-08-26 21:17:08 +02:00
|
|
|
|
# /var/lib/misc is for dnsmasq.leases.
|
|
|
|
|
stateDirs = "/var/lib/NetworkManager /var/lib/dhclient /var/lib/misc";
|
2012-09-19 14:13:34 +02:00
|
|
|
|
|
2013-01-03 18:55:56 +01:00
|
|
|
|
configFile = writeText "NetworkManager.conf" ''
|
2012-09-19 14:13:34 +02:00
|
|
|
|
[main]
|
|
|
|
|
plugins=keyfile
|
2017-06-02 13:05:22 +02:00
|
|
|
|
dhcp=${cfg.dhcp}
|
2018-06-29 19:41:46 +02:00
|
|
|
|
dns=${cfg.dns}
|
2012-09-19 14:13:34 +02:00
|
|
|
|
|
|
|
|
|
[keyfile]
|
2015-11-07 14:06:33 +01:00
|
|
|
|
${optionalString (cfg.unmanaged != [])
|
|
|
|
|
''unmanaged-devices=${lib.concatStringsSep ";" cfg.unmanaged}''}
|
2012-09-19 14:13:34 +02:00
|
|
|
|
|
|
|
|
|
[logging]
|
2017-06-02 13:05:22 +02:00
|
|
|
|
level=${cfg.logLevel}
|
2016-03-03 18:01:01 +01:00
|
|
|
|
|
|
|
|
|
[connection]
|
|
|
|
|
ipv6.ip6-privacy=2
|
2017-03-07 03:50:37 +01:00
|
|
|
|
ethernet.cloned-mac-address=${cfg.ethernet.macAddress}
|
|
|
|
|
wifi.cloned-mac-address=${cfg.wifi.macAddress}
|
2017-11-02 22:57:25 +01:00
|
|
|
|
${optionalString (cfg.wifi.powersave != null)
|
|
|
|
|
''wifi.powersave=${if cfg.wifi.powersave then "3" else "2"}''}
|
|
|
|
|
|
|
|
|
|
[device]
|
|
|
|
|
wifi.scan-rand-mac-address=${if cfg.wifi.scanRandMacAddress then "yes" else "no"}
|
2018-06-17 19:03:29 +02:00
|
|
|
|
|
|
|
|
|
${cfg.extraConfig}
|
2012-09-19 14:13:34 +02:00
|
|
|
|
'';
|
|
|
|
|
|
2013-11-09 16:29:18 +01:00
|
|
|
|
/*
|
2012-09-19 14:13:34 +02:00
|
|
|
|
[network-manager]
|
|
|
|
|
Identity=unix-group:networkmanager
|
|
|
|
|
Action=org.freedesktop.NetworkManager.*
|
|
|
|
|
ResultAny=yes
|
|
|
|
|
ResultInactive=no
|
|
|
|
|
ResultActive=yes
|
|
|
|
|
|
|
|
|
|
[modem-manager]
|
|
|
|
|
Identity=unix-group:networkmanager
|
2014-02-08 20:16:34 +01:00
|
|
|
|
Action=org.freedesktop.ModemManager*
|
2012-09-19 14:13:34 +02:00
|
|
|
|
ResultAny=yes
|
|
|
|
|
ResultInactive=no
|
|
|
|
|
ResultActive=yes
|
2013-11-09 16:29:18 +01:00
|
|
|
|
*/
|
|
|
|
|
polkitConf = ''
|
|
|
|
|
polkit.addRule(function(action, subject) {
|
|
|
|
|
if (
|
|
|
|
|
subject.isInGroup("networkmanager")
|
|
|
|
|
&& (action.id.indexOf("org.freedesktop.NetworkManager.") == 0
|
2014-02-08 20:16:34 +01:00
|
|
|
|
|| action.id.indexOf("org.freedesktop.ModemManager") == 0
|
2013-11-09 16:29:18 +01:00
|
|
|
|
))
|
|
|
|
|
{ return polkit.Result.YES; }
|
|
|
|
|
});
|
2012-09-19 14:13:34 +02:00
|
|
|
|
'';
|
|
|
|
|
|
2013-11-13 01:52:57 +01:00
|
|
|
|
ns = xs: writeText "nameservers" (
|
|
|
|
|
concatStrings (map (s: "nameserver ${s}\n") xs)
|
|
|
|
|
);
|
|
|
|
|
|
2013-08-16 00:35:57 +02:00
|
|
|
|
overrideNameserversScript = writeScript "02overridedns" ''
|
|
|
|
|
#!/bin/sh
|
2013-11-13 01:52:57 +01:00
|
|
|
|
tmp=`${coreutils}/bin/mktemp`
|
|
|
|
|
${gnused}/bin/sed '/nameserver /d' /etc/resolv.conf > $tmp
|
|
|
|
|
${gnugrep}/bin/grep 'nameserver ' /etc/resolv.conf | \
|
|
|
|
|
${gnugrep}/bin/grep -vf ${ns (cfg.appendNameservers ++ cfg.insertNameservers)} > $tmp.ns
|
|
|
|
|
${optionalString (cfg.appendNameservers != []) "${coreutils}/bin/cat $tmp $tmp.ns ${ns cfg.appendNameservers} > /etc/resolv.conf"}
|
|
|
|
|
${optionalString (cfg.insertNameservers != []) "${coreutils}/bin/cat $tmp ${ns cfg.insertNameservers} $tmp.ns > /etc/resolv.conf"}
|
|
|
|
|
${coreutils}/bin/rm -f $tmp $tmp.ns
|
2013-08-16 00:35:57 +02:00
|
|
|
|
'';
|
|
|
|
|
|
2015-03-08 18:30:15 +01:00
|
|
|
|
dispatcherTypesSubdirMap = {
|
|
|
|
|
"basic" = "";
|
2015-11-14 21:32:51 +01:00
|
|
|
|
"pre-up" = "pre-up.d/";
|
|
|
|
|
"pre-down" = "pre-down.d/";
|
2015-03-08 18:30:15 +01:00
|
|
|
|
};
|
|
|
|
|
|
2017-03-07 03:50:37 +01:00
|
|
|
|
macAddressOpt = mkOption {
|
|
|
|
|
type = types.either types.str (types.enum ["permanent" "preserve" "random" "stable"]);
|
|
|
|
|
default = "preserve";
|
|
|
|
|
example = "00:11:22:33:44:55";
|
|
|
|
|
description = ''
|
|
|
|
|
"XX:XX:XX:XX:XX:XX": MAC address of the interface.
|
|
|
|
|
<literal>permanent</literal>: use the permanent MAC address of the device.
|
|
|
|
|
<literal>preserve</literal>: don’t change the MAC address of the device upon activation.
|
|
|
|
|
<literal>random</literal>: generate a randomized value upon each connect.
|
|
|
|
|
<literal>stable</literal>: generate a stable, hashed MAC address.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2012-09-19 14:13:34 +02:00
|
|
|
|
in {
|
2012-03-15 08:19:17 +01:00
|
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
2013-08-16 00:35:57 +02:00
|
|
|
|
networking.networkmanager = {
|
|
|
|
|
|
|
|
|
|
enable = mkOption {
|
2013-10-28 16:14:15 +01:00
|
|
|
|
type = types.bool;
|
2013-08-16 00:35:57 +02:00
|
|
|
|
default = false;
|
|
|
|
|
description = ''
|
|
|
|
|
Whether to use NetworkManager to obtain an IP address and other
|
|
|
|
|
configuration for all network interfaces that are not manually
|
|
|
|
|
configured. If enabled, a group <literal>networkmanager</literal>
|
|
|
|
|
will be created. Add all users that should have permission
|
|
|
|
|
to change network settings to this group.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2014-02-12 12:29:18 +01:00
|
|
|
|
|
2018-06-17 19:03:29 +02:00
|
|
|
|
extraConfig = mkOption {
|
|
|
|
|
type = types.lines;
|
|
|
|
|
default = "";
|
|
|
|
|
description = ''
|
|
|
|
|
Configuration appended to the generated NetworkManager.conf.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2015-11-07 14:06:33 +01:00
|
|
|
|
unmanaged = mkOption {
|
|
|
|
|
type = types.listOf types.string;
|
|
|
|
|
default = [];
|
|
|
|
|
description = ''
|
|
|
|
|
List of interfaces that will not be managed by NetworkManager.
|
|
|
|
|
Interface name can be specified here, but if you need more fidelity
|
|
|
|
|
see "Device List Format" in NetworkManager.conf man page.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2015-04-10 17:02:57 +02:00
|
|
|
|
# Ugly hack for using the correct gnome3 packageSet
|
|
|
|
|
basePackages = mkOption {
|
2016-01-17 19:34:55 +01:00
|
|
|
|
type = types.attrsOf types.package;
|
2016-05-21 11:57:04 +02:00
|
|
|
|
default = { inherit networkmanager modemmanager wpa_supplicant
|
2018-02-25 03:23:58 +01:00
|
|
|
|
networkmanager-openvpn networkmanager-vpnc
|
|
|
|
|
networkmanager-openconnect networkmanager-fortisslvpn
|
2018-03-23 22:17:32 +01:00
|
|
|
|
networkmanager-l2tp networkmanager-iodine; };
|
2015-04-10 17:02:57 +02:00
|
|
|
|
internal = true;
|
|
|
|
|
};
|
|
|
|
|
|
2013-08-16 00:35:57 +02:00
|
|
|
|
packages = mkOption {
|
2013-10-28 16:14:15 +01:00
|
|
|
|
type = types.listOf types.path;
|
2013-08-16 00:35:57 +02:00
|
|
|
|
default = [ ];
|
|
|
|
|
description = ''
|
|
|
|
|
Extra packages that provide NetworkManager plugins.
|
|
|
|
|
'';
|
2015-04-10 17:02:57 +02:00
|
|
|
|
apply = list: (attrValues cfg.basePackages) ++ list;
|
2013-08-16 00:35:57 +02:00
|
|
|
|
};
|
|
|
|
|
|
2017-06-02 13:05:22 +02:00
|
|
|
|
dhcp = mkOption {
|
|
|
|
|
type = types.enum [ "dhclient" "dhcpcd" "internal" ];
|
|
|
|
|
default = "dhclient";
|
|
|
|
|
description = ''
|
|
|
|
|
Which program (or internal library) should be used for DHCP.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
logLevel = mkOption {
|
|
|
|
|
type = types.enum [ "OFF" "ERR" "WARN" "INFO" "DEBUG" "TRACE" ];
|
|
|
|
|
default = "WARN";
|
|
|
|
|
description = ''
|
|
|
|
|
Set the default logging verbosity level.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2013-11-13 01:52:57 +01:00
|
|
|
|
appendNameservers = mkOption {
|
2015-06-15 18:18:46 +02:00
|
|
|
|
type = types.listOf types.str;
|
2013-11-13 01:52:57 +01:00
|
|
|
|
default = [];
|
2013-08-16 00:35:57 +02:00
|
|
|
|
description = ''
|
2013-11-13 01:52:57 +01:00
|
|
|
|
A list of name servers that should be appended
|
|
|
|
|
to the ones configured in NetworkManager or received by DHCP.
|
2013-08-20 13:36:01 +02:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2013-11-13 01:52:57 +01:00
|
|
|
|
insertNameservers = mkOption {
|
2015-06-15 18:18:46 +02:00
|
|
|
|
type = types.listOf types.str;
|
2013-11-13 01:52:57 +01:00
|
|
|
|
default = [];
|
2013-08-20 13:36:01 +02:00
|
|
|
|
description = ''
|
2013-11-13 01:52:57 +01:00
|
|
|
|
A list of name servers that should be inserted before
|
|
|
|
|
the ones configured in NetworkManager or received by DHCP.
|
2013-08-16 00:35:57 +02:00
|
|
|
|
'';
|
|
|
|
|
};
|
2012-03-15 08:19:17 +01:00
|
|
|
|
|
2017-03-07 03:50:37 +01:00
|
|
|
|
ethernet.macAddress = macAddressOpt;
|
2017-11-02 22:57:25 +01:00
|
|
|
|
|
|
|
|
|
wifi = {
|
|
|
|
|
macAddress = macAddressOpt;
|
|
|
|
|
|
|
|
|
|
powersave = mkOption {
|
|
|
|
|
type = types.nullOr types.bool;
|
|
|
|
|
default = null;
|
|
|
|
|
description = ''
|
|
|
|
|
Whether to enable Wi-Fi power saving.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
scanRandMacAddress = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
description = ''
|
|
|
|
|
Whether to enable MAC address randomization of a Wi-Fi device
|
|
|
|
|
during scanning.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
2017-03-07 03:50:37 +01:00
|
|
|
|
|
2018-05-03 14:05:43 +02:00
|
|
|
|
dns = mkOption {
|
2018-06-29 19:41:46 +02:00
|
|
|
|
type = types.enum [ "default" "dnsmasq" "unbound" "systemd-resolved" "none" ];
|
|
|
|
|
default = "default";
|
2017-10-14 08:40:22 +02:00
|
|
|
|
description = ''
|
2018-06-29 19:41:46 +02:00
|
|
|
|
Set the DNS (<literal>resolv.conf</literal>) processing mode.
|
|
|
|
|
</para>
|
|
|
|
|
<para>
|
2018-05-03 14:05:43 +02:00
|
|
|
|
Options:
|
2018-06-29 19:41:46 +02:00
|
|
|
|
<variablelist>
|
|
|
|
|
<varlistentry>
|
|
|
|
|
<term><literal>"default"</literal></term>
|
|
|
|
|
<listitem><para>
|
|
|
|
|
NetworkManager will update <literal>/etc/resolv.conf</literal> to
|
|
|
|
|
reflect the nameservers provided by currently active connections.
|
|
|
|
|
</para></listitem>
|
|
|
|
|
</varlistentry>
|
|
|
|
|
<varlistentry>
|
|
|
|
|
<term><literal>"dnsmasq"</literal></term>
|
|
|
|
|
<listitem>
|
|
|
|
|
<para>
|
|
|
|
|
Enable NetworkManager's dnsmasq integration. NetworkManager will
|
|
|
|
|
run dnsmasq as a local caching nameserver, using a "split DNS"
|
|
|
|
|
configuration if you are connected to a VPN, and then update
|
|
|
|
|
<literal>resolv.conf</literal> to point to the local nameserver.
|
|
|
|
|
</para>
|
|
|
|
|
<para>
|
|
|
|
|
It is possible to pass custom options to the dnsmasq instance by
|
|
|
|
|
adding them to files in the
|
|
|
|
|
<literal>/etc/NetworkManager/dnsmasq.d/</literal> directory.
|
|
|
|
|
</para>
|
|
|
|
|
<para>
|
|
|
|
|
When multiple upstream servers are available, dnsmasq will
|
|
|
|
|
initially contact them in parallel and then use the fastest to
|
|
|
|
|
respond, probing again other servers after some time. This
|
|
|
|
|
behavior can be modified passing the
|
|
|
|
|
<literal>all-servers</literal> or <literal>strict-order</literal>
|
|
|
|
|
options to dnsmasq (see the manual page for more details).
|
|
|
|
|
</para>
|
|
|
|
|
<para>
|
|
|
|
|
Note that this option causes NetworkManager to launch and manage
|
|
|
|
|
its own instance of the dnsmasq daemon, which is
|
|
|
|
|
<emphasis>not</emphasis> the same as setting
|
|
|
|
|
<literal>services.dnsmasq.enable = true;</literal>.
|
|
|
|
|
</para>
|
|
|
|
|
</listitem>
|
|
|
|
|
</varlistentry>
|
|
|
|
|
<varlistentry>
|
|
|
|
|
<term><literal>"unbound"</literal></term>
|
|
|
|
|
<listitem><para>
|
|
|
|
|
NetworkManager will talk to unbound and dnssec-triggerd,
|
|
|
|
|
providing a "split DNS" configuration with DNSSEC support.
|
|
|
|
|
<literal>/etc/resolv.conf</literal> will be managed by
|
|
|
|
|
dnssec-trigger daemon.
|
|
|
|
|
</para></listitem>
|
|
|
|
|
</varlistentry>
|
|
|
|
|
<varlistentry>
|
|
|
|
|
<term><literal>"systemd-resolved"</literal></term>
|
|
|
|
|
<listitem><para>
|
|
|
|
|
NetworkManager will push the DNS configuration to systemd-resolved.
|
|
|
|
|
</para></listitem>
|
|
|
|
|
</varlistentry>
|
|
|
|
|
<varlistentry>
|
|
|
|
|
<term><literal>"none"</literal></term>
|
|
|
|
|
<listitem><para>
|
|
|
|
|
NetworkManager will not modify resolv.conf.
|
|
|
|
|
</para></listitem>
|
|
|
|
|
</varlistentry>
|
|
|
|
|
</variablelist>
|
2017-10-14 08:40:22 +02:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2015-03-08 18:30:15 +01:00
|
|
|
|
dispatcherScripts = mkOption {
|
|
|
|
|
type = types.listOf (types.submodule {
|
|
|
|
|
options = {
|
|
|
|
|
source = mkOption {
|
2017-04-09 14:14:04 +02:00
|
|
|
|
type = types.path;
|
2015-03-08 18:30:15 +01:00
|
|
|
|
description = ''
|
2017-04-09 14:14:04 +02:00
|
|
|
|
A script.
|
2015-03-08 18:30:15 +01:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
type = mkOption {
|
2017-06-02 13:05:22 +02:00
|
|
|
|
type = types.enum (attrNames dispatcherTypesSubdirMap);
|
2015-03-08 18:30:15 +01:00
|
|
|
|
default = "basic";
|
|
|
|
|
description = ''
|
|
|
|
|
Dispatcher hook type. Only basic hooks are currently available.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
default = [];
|
|
|
|
|
description = ''
|
|
|
|
|
A list of scripts which will be executed in response to network events.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2017-10-24 23:55:05 +02:00
|
|
|
|
|
|
|
|
|
enableStrongSwan = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
|
|
|
|
description = ''
|
|
|
|
|
Enable the StrongSwan plugin.
|
|
|
|
|
</para><para>
|
|
|
|
|
If you enable this option the
|
|
|
|
|
<literal>networkmanager_strongswan</literal> plugin will be added to
|
|
|
|
|
the <option>networking.networkmanager.packages</option> option
|
|
|
|
|
so you don't need to to that yourself.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2018-07-05 23:22:09 +02:00
|
|
|
|
|
|
|
|
|
dynamicHosts = {
|
|
|
|
|
enable = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
|
|
|
|
description = ''
|
|
|
|
|
Enabling this option requires the
|
|
|
|
|
<option>networking.networkmanager.dns</option> option to be
|
|
|
|
|
set to <literal>dnsmasq</literal>. If enabled, the directories
|
|
|
|
|
defined by the
|
|
|
|
|
<option>networking.networkmanager.dynamicHosts.hostsDirs</option>
|
|
|
|
|
option will be set up when the service starts. The dnsmasq instance
|
|
|
|
|
managed by NetworkManager will then watch those directories for
|
|
|
|
|
hosts files (see the <literal>--hostsdir</literal> option of
|
|
|
|
|
dnsmasq). This way a non-privileged user can add or override DNS
|
|
|
|
|
entries on the local system (depending on what hosts directories
|
|
|
|
|
that are configured)..
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
hostsDirs = mkOption {
|
|
|
|
|
type = with types; attrsOf (submodule {
|
|
|
|
|
options = {
|
|
|
|
|
user = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
default = "root";
|
|
|
|
|
description = ''
|
|
|
|
|
The user that will own the hosts directory.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
group = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
default = "root";
|
|
|
|
|
description = ''
|
|
|
|
|
The group that will own the hosts directory.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
default = {};
|
|
|
|
|
description = ''
|
|
|
|
|
Defines a set of directories (relative to
|
|
|
|
|
<literal>/run/NetworkManager/hostdirs</literal>) that dnsmasq will
|
|
|
|
|
watch for hosts files.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
2012-03-15 08:19:17 +01:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
2012-09-19 14:13:34 +02:00
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
2018-07-05 23:22:09 +02:00
|
|
|
|
assertions = [
|
|
|
|
|
{ assertion = config.networking.wireless.enable == false;
|
|
|
|
|
message = "You can not use networking.networkmanager with networking.wireless";
|
|
|
|
|
}
|
|
|
|
|
{ assertion = !dynamicHostsEnabled || (dynamicHostsEnabled && cfg.dns == "dnsmasq");
|
|
|
|
|
message = ''
|
|
|
|
|
To use networking.networkmanager.dynamicHosts you also need to set
|
|
|
|
|
networking.networkmanager.dns = "dnsmasq"
|
|
|
|
|
'';
|
|
|
|
|
}
|
|
|
|
|
];
|
2013-03-31 21:18:51 +02:00
|
|
|
|
|
2016-05-21 11:56:32 +02:00
|
|
|
|
environment.etc = with cfg.basePackages; [
|
2013-01-03 18:55:56 +01:00
|
|
|
|
{ source = configFile;
|
|
|
|
|
target = "NetworkManager/NetworkManager.conf";
|
|
|
|
|
}
|
2018-02-25 03:23:58 +01:00
|
|
|
|
{ source = "${networkmanager-openvpn}/etc/NetworkManager/VPN/nm-openvpn-service.name";
|
2013-05-13 17:52:19 +02:00
|
|
|
|
target = "NetworkManager/VPN/nm-openvpn-service.name";
|
|
|
|
|
}
|
2018-02-25 03:23:58 +01:00
|
|
|
|
{ source = "${networkmanager-vpnc}/etc/NetworkManager/VPN/nm-vpnc-service.name";
|
2013-07-10 16:43:26 +02:00
|
|
|
|
target = "NetworkManager/VPN/nm-vpnc-service.name";
|
|
|
|
|
}
|
2018-02-25 03:23:58 +01:00
|
|
|
|
{ source = "${networkmanager-openconnect}/etc/NetworkManager/VPN/nm-openconnect-service.name";
|
2013-07-10 16:43:26 +02:00
|
|
|
|
target = "NetworkManager/VPN/nm-openconnect-service.name";
|
|
|
|
|
}
|
2018-02-25 03:23:58 +01:00
|
|
|
|
{ source = "${networkmanager-fortisslvpn}/etc/NetworkManager/VPN/nm-fortisslvpn-service.name";
|
2017-05-19 14:42:36 +02:00
|
|
|
|
target = "NetworkManager/VPN/nm-fortisslvpn-service.name";
|
|
|
|
|
}
|
2018-02-25 03:23:58 +01:00
|
|
|
|
{ source = "${networkmanager-l2tp}/etc/NetworkManager/VPN/nm-l2tp-service.name";
|
2015-03-24 12:08:05 +01:00
|
|
|
|
target = "NetworkManager/VPN/nm-l2tp-service.name";
|
|
|
|
|
}
|
2016-08-25 21:58:56 +02:00
|
|
|
|
{ source = "${networkmanager_strongswan}/etc/NetworkManager/VPN/nm-strongswan-service.name";
|
|
|
|
|
target = "NetworkManager/VPN/nm-strongswan-service.name";
|
|
|
|
|
}
|
2018-02-25 03:23:58 +01:00
|
|
|
|
{ source = "${networkmanager-iodine}/etc/NetworkManager/VPN/nm-iodine-service.name";
|
2017-08-15 23:42:48 +02:00
|
|
|
|
target = "NetworkManager/VPN/nm-iodine-service.name";
|
|
|
|
|
}
|
2014-05-05 20:58:51 +02:00
|
|
|
|
] ++ optional (cfg.appendNameservers == [] || cfg.insertNameservers == [])
|
2013-08-16 00:35:57 +02:00
|
|
|
|
{ source = overrideNameserversScript;
|
|
|
|
|
target = "NetworkManager/dispatcher.d/02overridedns";
|
2015-03-08 18:30:15 +01:00
|
|
|
|
}
|
2017-07-05 00:29:23 +02:00
|
|
|
|
++ lib.imap1 (i: s: {
|
2017-04-09 14:14:04 +02:00
|
|
|
|
inherit (s) source;
|
2015-03-08 18:30:15 +01:00
|
|
|
|
target = "NetworkManager/dispatcher.d/${dispatcherTypesSubdirMap.${s.type}}03userscript${lib.fixedWidthNumber 4 i}";
|
2018-07-05 23:22:09 +02:00
|
|
|
|
}) cfg.dispatcherScripts
|
|
|
|
|
++ optional (dynamicHostsEnabled)
|
|
|
|
|
{ target = "NetworkManager/dnsmasq.d/dyndns.conf";
|
|
|
|
|
text = concatMapStrings (n: ''
|
|
|
|
|
hostsdir=/run/NetworkManager/hostsdirs/${n}
|
|
|
|
|
'') (attrNames cfg.dynamicHosts.hostsDirs);
|
|
|
|
|
};
|
2012-09-19 14:13:34 +02:00
|
|
|
|
|
2015-04-10 17:02:57 +02:00
|
|
|
|
environment.systemPackages = cfg.packages;
|
2012-03-15 08:19:17 +01:00
|
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
|
users.groups = [{
|
2012-09-19 14:13:34 +02:00
|
|
|
|
name = "networkmanager";
|
|
|
|
|
gid = config.ids.gids.networkmanager;
|
2015-10-29 09:58:38 +01:00
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
name = "nm-openvpn";
|
2015-12-08 17:46:57 +01:00
|
|
|
|
gid = config.ids.gids.nm-openvpn;
|
2015-10-29 09:58:38 +01:00
|
|
|
|
}];
|
2018-06-30 01:58:35 +02:00
|
|
|
|
users.users = [{
|
2015-10-29 09:58:38 +01:00
|
|
|
|
name = "nm-openvpn";
|
2015-12-08 17:46:57 +01:00
|
|
|
|
uid = config.ids.uids.nm-openvpn;
|
2017-04-11 04:41:55 +02:00
|
|
|
|
extraGroups = [ "networkmanager" ];
|
2017-08-15 23:42:48 +02:00
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
name = "nm-iodine";
|
|
|
|
|
isSystemUser = true;
|
|
|
|
|
group = "networkmanager";
|
2015-10-29 09:58:38 +01:00
|
|
|
|
}];
|
2012-09-19 14:13:34 +02:00
|
|
|
|
|
2013-01-03 18:55:56 +01:00
|
|
|
|
systemd.packages = cfg.packages;
|
|
|
|
|
|
2016-08-14 12:27:14 +02:00
|
|
|
|
systemd.services."network-manager" = {
|
2013-01-03 18:55:56 +01:00
|
|
|
|
wantedBy = [ "network.target" ];
|
2017-03-07 03:50:37 +01:00
|
|
|
|
restartTriggers = [ configFile ];
|
2016-08-14 12:27:14 +02:00
|
|
|
|
|
|
|
|
|
preStart = ''
|
2012-09-19 14:13:34 +02:00
|
|
|
|
mkdir -m 700 -p /etc/NetworkManager/system-connections
|
2017-10-31 12:14:00 +01:00
|
|
|
|
mkdir -m 700 -p /etc/ipsec.d
|
2012-09-19 14:13:34 +02:00
|
|
|
|
mkdir -m 755 -p ${stateDirs}
|
|
|
|
|
'';
|
|
|
|
|
};
|
2012-03-15 08:19:17 +01:00
|
|
|
|
|
2018-07-05 23:22:09 +02:00
|
|
|
|
systemd.services.nm-setup-hostsdirs = mkIf dynamicHostsEnabled {
|
|
|
|
|
wantedBy = [ "network-manager.service" ];
|
|
|
|
|
before = [ "network-manager.service" ];
|
|
|
|
|
partOf = [ "network-manager.service" ];
|
|
|
|
|
script = concatStrings (mapAttrsToList (n: d: ''
|
|
|
|
|
mkdir -p "/run/NetworkManager/hostsdirs/${n}"
|
|
|
|
|
chown "${d.user}:${d.group}" "/run/NetworkManager/hostsdirs/${n}"
|
|
|
|
|
chmod 0775 "/run/NetworkManager/hostsdirs/${n}"
|
|
|
|
|
'') cfg.dynamicHosts.hostsDirs);
|
|
|
|
|
serviceConfig = {
|
|
|
|
|
Type = "oneshot";
|
|
|
|
|
RemainAfterExist = true;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2013-01-03 18:55:56 +01:00
|
|
|
|
# Turn off NixOS' network management
|
|
|
|
|
networking = {
|
|
|
|
|
useDHCP = false;
|
2017-01-22 20:29:41 +01:00
|
|
|
|
# use mkDefault to trigger the assertion about the conflict above
|
|
|
|
|
wireless.enable = lib.mkDefault false;
|
2013-01-03 18:55:56 +01:00
|
|
|
|
};
|
2012-09-19 14:13:34 +02:00
|
|
|
|
|
2013-11-09 16:29:18 +01:00
|
|
|
|
security.polkit.extraConfig = polkitConf;
|
2012-09-19 14:13:34 +02:00
|
|
|
|
|
2017-10-24 23:55:05 +02:00
|
|
|
|
networking.networkmanager.packages =
|
|
|
|
|
mkIf cfg.enableStrongSwan [ pkgs.networkmanager_strongswan ];
|
|
|
|
|
|
|
|
|
|
services.dbus.packages =
|
|
|
|
|
optional cfg.enableStrongSwan pkgs.strongswanNM ++ cfg.packages;
|
2012-09-19 14:13:34 +02:00
|
|
|
|
|
|
|
|
|
services.udev.packages = cfg.packages;
|
2012-03-15 08:19:17 +01:00
|
|
|
|
};
|
|
|
|
|
}
|