mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-13 05:05:29 +03:00
nixos/networkmanager: split ModemManager bits into own module
this should not result in any observable change by default, the motivation is to make working on either one of these components in isolation of the other a bit easier.
This commit is contained in:
parent
e7e64b5141
commit
0deadd5baf
4 changed files with 102 additions and 42 deletions
|
@ -28,6 +28,8 @@
|
|||
|
||||
- [MaryTTS](https://github.com/marytts/marytts), an open-source, multilingual text-to-speech synthesis system written in pure Java. Available as [services.marytts](options.html#opt-services.marytts).
|
||||
|
||||
- [networking.modemmanager](options.html#opt-networking.modemmanager) has been split out of [networking.networkmanager](options.html#opt-networking.networkmanager). NetworkManager still enables ModemManager by default, but options exist now to run NetworkManager without ModemManager.
|
||||
|
||||
- [Conduwuit](https://conduwuit.puppyirl.gay/), a federated chat server implementing the Matrix protocol, forked from Conduit. Available as [services.conduwuit](#opt-services.conduwuit.enable).
|
||||
|
||||
- [Traccar](https://www.traccar.org/), a modern GPS Tracking Platform. Available as [services.traccar](#opt-services.traccar.enable).
|
||||
|
|
|
@ -1135,6 +1135,7 @@
|
|||
./services/networking/miredo.nix
|
||||
./services/networking/mjpg-streamer.nix
|
||||
./services/networking/mmsd.nix
|
||||
./services/networking/modemmanager.nix
|
||||
./services/networking/monero.nix
|
||||
./services/networking/morty.nix
|
||||
./services/networking/mosquitto.nix
|
||||
|
|
90
nixos/modules/services/networking/modemmanager.nix
Normal file
90
nixos/modules/services/networking/modemmanager.nix
Normal file
|
@ -0,0 +1,90 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.networking.modemmanager;
|
||||
in
|
||||
{
|
||||
meta = {
|
||||
maintainers = lib.teams.freedesktop.members;
|
||||
};
|
||||
|
||||
options = with lib; {
|
||||
networking.modemmanager = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to use ModemManager to manage modem devices.
|
||||
This is usually used by some higher layer manager such as NetworkManager
|
||||
but can be used standalone especially if using a modem for non-IP
|
||||
connectivity (e.g. GPS).
|
||||
'';
|
||||
};
|
||||
|
||||
fccUnlockScripts = mkOption {
|
||||
type = types.listOf (
|
||||
types.submodule {
|
||||
options = {
|
||||
id = mkOption {
|
||||
type = types.str;
|
||||
description = "vid:pid of either the PCI or USB vendor and product ID";
|
||||
};
|
||||
path = mkOption {
|
||||
type = types.path;
|
||||
description = "Path to the unlock script";
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
default = [ ];
|
||||
example = literalExpression ''[{ id = "03f0:4e1d"; path = "''${pkgs.modemmanager}/share/ModemManager/fcc-unlock.available.d/03f0:4e1d"; }]'';
|
||||
description = ''
|
||||
List of FCC unlock scripts to enable on the system, behaving as described in
|
||||
https://modemmanager.org/docs/modemmanager/fcc-unlock/#integration-with-third-party-fcc-unlock-tools.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.etc = builtins.listToAttrs (
|
||||
map (
|
||||
e:
|
||||
lib.nameValuePair "ModemManager/fcc-unlock.d/${e.id}" {
|
||||
source = e.path;
|
||||
}
|
||||
) cfg.fccUnlockScripts
|
||||
);
|
||||
|
||||
systemd.services.ModemManager = {
|
||||
aliases = [ "dbus-org.freedesktop.ModemManager1.service" ];
|
||||
path = lib.optionals (cfg.fccUnlockScripts != [ ]) [
|
||||
pkgs.libqmi
|
||||
pkgs.libmbim
|
||||
];
|
||||
};
|
||||
|
||||
/*
|
||||
[modem-manager]
|
||||
Identity=unix-group:networkmanager
|
||||
Action=org.freedesktop.ModemManager*
|
||||
ResultAny=yes
|
||||
ResultInactive=no
|
||||
ResultActive=yes
|
||||
*/
|
||||
security.polkit.enable = true;
|
||||
security.polkit.extraConfig = ''
|
||||
polkit.addRule(function(action, subject) {
|
||||
if (
|
||||
subject.isInGroup("networkmanager")
|
||||
&& action.id.indexOf("org.freedesktop.ModemManager") == 0
|
||||
)
|
||||
{ return polkit.Result.YES; }
|
||||
});
|
||||
'';
|
||||
|
||||
environment.systemPackages = [ pkgs.modemmanager ];
|
||||
systemd.packages = [ pkgs.modemmanager ];
|
||||
services.dbus.packages = [ pkgs.modemmanager ];
|
||||
services.udev.packages = [ pkgs.modemmanager ];
|
||||
};
|
||||
}
|
|
@ -43,21 +43,13 @@ let
|
|||
ResultAny=yes
|
||||
ResultInactive=no
|
||||
ResultActive=yes
|
||||
|
||||
[modem-manager]
|
||||
Identity=unix-group:networkmanager
|
||||
Action=org.freedesktop.ModemManager*
|
||||
ResultAny=yes
|
||||
ResultInactive=no
|
||||
ResultActive=yes
|
||||
*/
|
||||
polkitConf = ''
|
||||
polkit.addRule(function(action, subject) {
|
||||
if (
|
||||
subject.isInGroup("networkmanager")
|
||||
&& (action.id.indexOf("org.freedesktop.NetworkManager.") == 0
|
||||
|| action.id.indexOf("org.freedesktop.ModemManager") == 0
|
||||
))
|
||||
&& action.id.indexOf("org.freedesktop.NetworkManager.") == 0
|
||||
)
|
||||
{ return polkit.Result.YES; }
|
||||
});
|
||||
'';
|
||||
|
@ -115,7 +107,6 @@ let
|
|||
};
|
||||
|
||||
packages = [
|
||||
pkgs.modemmanager
|
||||
pkgs.networkmanager
|
||||
]
|
||||
++ cfg.plugins
|
||||
|
@ -358,26 +349,6 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
fccUnlockScripts = mkOption {
|
||||
type = types.listOf (types.submodule {
|
||||
options = {
|
||||
id = mkOption {
|
||||
type = types.str;
|
||||
description = "vid:pid of either the PCI or USB vendor and product ID";
|
||||
};
|
||||
path = mkOption {
|
||||
type = types.path;
|
||||
description = "Path to the unlock script";
|
||||
};
|
||||
};
|
||||
});
|
||||
default = [ ];
|
||||
example = literalExpression ''[{ id = "03f0:4e1d"; path = "''${pkgs.modemmanager}/share/ModemManager/fcc-unlock.available.d/03f0:4e1d"; }]'';
|
||||
description = ''
|
||||
List of FCC unlock scripts to enable on the system, behaving as described in
|
||||
https://modemmanager.org/docs/modemmanager/fcc-unlock/#integration-with-third-party-fcc-unlock-tools.
|
||||
'';
|
||||
};
|
||||
ensureProfiles = {
|
||||
profiles = with lib.types; mkOption {
|
||||
type = attrsOf (submodule {
|
||||
|
@ -480,7 +451,7 @@ in
|
|||
might conflict with vendor-provided unlock scripts, and should
|
||||
be a conscious decision on a per-device basis.
|
||||
Instead it's recommended to use the
|
||||
`networking.networkmanager.fccUnlockScripts` option.
|
||||
`networking.modemmanager.fccUnlockScripts` option.
|
||||
'')
|
||||
(mkRemovedOptionModule [ "networking" "networkmanager" "dynamicHosts" ] ''
|
||||
This option was removed because allowing (multiple) regular users to
|
||||
|
@ -493,6 +464,10 @@ in
|
|||
(mkRemovedOptionModule [ "networking" "networkmanager" "firewallBackend" ] ''
|
||||
This option was removed as NixOS is now using iptables-nftables-compat even when using iptables, therefore Networkmanager now uses the nftables backend unconditionally.
|
||||
'')
|
||||
(mkRenamedOptionModule
|
||||
[ "networking" "networkmanager" "fccUnlockScripts" ]
|
||||
[ "networking" "modemmanager" "fccUnlockScripts" ]
|
||||
)
|
||||
];
|
||||
|
||||
|
||||
|
@ -526,11 +501,6 @@ in
|
|||
source = "${pkg}/lib/NetworkManager/${pkg.networkManagerPlugin}";
|
||||
})
|
||||
cfg.plugins)
|
||||
// builtins.listToAttrs (map
|
||||
(e: nameValuePair "ModemManager/fcc-unlock.d/${e.id}" {
|
||||
source = e.path;
|
||||
})
|
||||
cfg.fccUnlockScripts)
|
||||
// optionalAttrs (cfg.appendNameservers != [ ] || cfg.insertNameservers != [ ])
|
||||
{
|
||||
"NetworkManager/dispatcher.d/02overridedns".source = overrideNameserversScript;
|
||||
|
@ -590,11 +560,6 @@ in
|
|||
wantedBy = [ "network-online.target" ];
|
||||
};
|
||||
|
||||
systemd.services.ModemManager = {
|
||||
aliases = [ "dbus-org.freedesktop.ModemManager1.service" ];
|
||||
path = lib.optionals (cfg.fccUnlockScripts != []) [ pkgs.libqmi pkgs.libmbim ];
|
||||
};
|
||||
|
||||
systemd.services.NetworkManager-dispatcher = {
|
||||
wantedBy = [ "network.target" ];
|
||||
restartTriggers = [ configFile overrideNameserversScript ];
|
||||
|
@ -654,6 +619,8 @@ in
|
|||
})
|
||||
|
||||
{
|
||||
modemmanager.enable = lib.mkDefault true;
|
||||
|
||||
networkmanager.connectionConfig = {
|
||||
"ethernet.cloned-mac-address" = cfg.ethernet.macAddress;
|
||||
"wifi.cloned-mac-address" = cfg.wifi.macAddress;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue