about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/hardware/usb-wwan.nix
blob: 69673872cf9b7f2045ee7a61f7f44f523132c4c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{ config, lib, pkgs, ... }:

with lib;

{
  ###### interface

  options = {

    hardware.usbWwan = {
      enable = mkOption {
        type = types.bool;
        default = false;
        description = lib.mdDoc ''
          Enable this option to support USB WWAN adapters.
        '';
      };
    };
  };

  ###### implementation

  config = mkIf config.hardware.usbWwan.enable {
    # Attaches device specific handlers.
    services.udev.packages = with pkgs; [ usb-modeswitch-data ];

    # Triggered by udev, usb-modeswitch creates systemd services via a
    # template unit in the usb-modeswitch package.
    systemd.packages = with pkgs; [ usb-modeswitch ];

    # The systemd service requires the usb-modeswitch-data. The
    # usb-modeswitch package intends to discover this via the
    # filesystem at /usr/share/usb_modeswitch, and merge it with user
    # configuration in /etc/usb_modeswitch.d. Configuring the correct
    # path in the package is difficult, as it would cause a cyclic
    # dependency.
    environment.etc."usb_modeswitch.d".source = "${pkgs.usb-modeswitch-data}/share/usb_modeswitch";
  };
}