1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8let
9 cfg = config.programs.qgroundcontrol;
10in
11{
12
13 options = {
14 programs.qgroundcontrol = {
15 enable = lib.mkEnableOption "qgroundcontrol";
16
17 package = lib.mkPackageOption pkgs "qgroundcontrol" { };
18
19 blacklistModemManagerFromTTYUSB = lib.mkOption {
20 type = lib.types.bool;
21 default = true;
22 description = ''
23 Disallow ModemManager from interfering with serial connections that QGroundControl might use.
24
25 Note that if you use a modem that's connected via USB, you might want to disable this option.
26 '';
27 };
28 };
29 };
30
31 config = lib.mkIf cfg.enable {
32 # ModemManager is known to interfere with serial connections;
33 # QGC recommends disabling it, but we don't want to if we can avoid it
34 # Instead, we blacklist tty devices using udev rules, which is a more targeted approach
35 services.udev = lib.mkIf cfg.blacklistModemManagerFromTTYUSB {
36 enable = true;
37 extraRules = ''
38 # nixos/qgroundcontrol: Blacklist ttyUSB devices from ModemManager
39 SUBSYSTEM=="tty", KERNEL=="ttyUSB*", ENV{ID_MM_DEVICE_IGNORE}="1"
40 '';
41 };
42
43 # Add to systemPackages for desktop entry file
44 environment.systemPackages = [ cfg.package ];
45 };
46
47 meta.maintainers = pkgs.qgroundcontrol.meta.maintainers;
48}