Skip to content

Commit a01b0bf

Browse files
authored
nixos/networkmanager: split modemmanager into a separate module (#316824)
2 parents 0882c5d + efc3208 commit a01b0bf

File tree

4 files changed

+323
-190
lines changed

4 files changed

+323
-190
lines changed

nixos/doc/manual/release-notes/rl-2505.section.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
- [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).
3232

33+
- [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.
34+
3335
- [Conduwuit](https://conduwuit.puppyirl.gay/), a federated chat server implementing the Matrix protocol, forked from Conduit. Available as [services.conduwuit](#opt-services.conduwuit.enable).
3436

3537
- [Traccar](https://www.traccar.org/), a modern GPS Tracking Platform. Available as [services.traccar](#opt-services.traccar.enable).

nixos/modules/module-list.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,7 @@
11371137
./services/networking/miredo.nix
11381138
./services/networking/mjpg-streamer.nix
11391139
./services/networking/mmsd.nix
1140+
./services/networking/modemmanager.nix
11401141
./services/networking/monero.nix
11411142
./services/networking/morty.nix
11421143
./services/networking/mosquitto.nix
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
7+
let
8+
cfg = config.networking.modemmanager;
9+
in
10+
{
11+
meta = {
12+
maintainers = lib.teams.freedesktop.members;
13+
};
14+
15+
options = with lib; {
16+
networking.modemmanager = {
17+
enable = mkOption {
18+
type = types.bool;
19+
default = false;
20+
description = ''
21+
Whether to use ModemManager to manage modem devices.
22+
This is usually used by some higher layer manager such as NetworkManager
23+
but can be used standalone especially if using a modem for non-IP
24+
connectivity (e.g. GPS).
25+
'';
26+
};
27+
28+
package = mkPackageOption pkgs "modemmanager" { };
29+
30+
fccUnlockScripts = mkOption {
31+
type = types.listOf (
32+
types.submodule {
33+
options = {
34+
id = mkOption {
35+
type = types.str;
36+
description = "vid:pid of either the PCI or USB vendor and product ID";
37+
};
38+
path = mkOption {
39+
type = types.path;
40+
description = "Path to the unlock script";
41+
};
42+
};
43+
}
44+
);
45+
default = [ ];
46+
example = literalExpression ''[{ id = "03f0:4e1d"; path = "''${pkgs.modemmanager}/share/ModemManager/fcc-unlock.available.d/03f0:4e1d"; }]'';
47+
description = ''
48+
List of FCC unlock scripts to enable on the system, behaving as described in
49+
https://modemmanager.org/docs/modemmanager/fcc-unlock/#integration-with-third-party-fcc-unlock-tools.
50+
'';
51+
};
52+
};
53+
};
54+
55+
config = lib.mkIf cfg.enable {
56+
environment.etc = builtins.listToAttrs (
57+
map (
58+
e:
59+
lib.nameValuePair "ModemManager/fcc-unlock.d/${e.id}" {
60+
source = e.path;
61+
}
62+
) cfg.fccUnlockScripts
63+
);
64+
65+
systemd.services.ModemManager = {
66+
aliases = [ "dbus-org.freedesktop.ModemManager1.service" ];
67+
path = lib.optionals (cfg.fccUnlockScripts != [ ]) [
68+
pkgs.libqmi
69+
pkgs.libmbim
70+
];
71+
};
72+
73+
/*
74+
[modem-manager]
75+
Identity=unix-group:networkmanager
76+
Action=org.freedesktop.ModemManager*
77+
ResultAny=yes
78+
ResultInactive=no
79+
ResultActive=yes
80+
*/
81+
security.polkit.enable = true;
82+
security.polkit.extraConfig = ''
83+
polkit.addRule(function(action, subject) {
84+
if (
85+
subject.isInGroup("networkmanager")
86+
&& action.id.indexOf("org.freedesktop.ModemManager") == 0
87+
)
88+
{ return polkit.Result.YES; }
89+
});
90+
'';
91+
92+
environment.systemPackages = [ cfg.package ];
93+
systemd.packages = [ cfg.package ];
94+
services.dbus.packages = [ cfg.package ];
95+
services.udev.packages = [ cfg.package ];
96+
};
97+
}

0 commit comments

Comments
 (0)