2017-02-18 03:35:58 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
2023-07-20 20:20:33 +00:00
|
|
|
hardware.usb-modeswitch = {
|
2024-08-24 20:05:30 +00:00
|
|
|
enable = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2017-02-18 03:35:58 +00:00
|
|
|
default = false;
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2023-07-20 20:20:33 +00:00
|
|
|
Enable this option to support certain USB WLAN and WWAN adapters.
|
|
|
|
|
|
|
|
These network adapters initial present themselves as Flash Drives containing their drivers.
|
|
|
|
This option enables automatic switching to the networking mode.
|
2017-02-18 03:35:58 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2023-07-20 20:20:33 +00:00
|
|
|
imports = [
|
2024-08-24 20:05:30 +00:00
|
|
|
(lib.mkRenamedOptionModule ["hardware" "usbWwan" ] ["hardware" "usb-modeswitch" ])
|
2023-07-20 20:20:33 +00:00
|
|
|
];
|
|
|
|
|
2024-08-24 20:05:30 +00:00
|
|
|
config = lib.mkIf config.hardware.usb-modeswitch.enable {
|
2019-05-05 08:23:32 +00:00
|
|
|
# Attaches device specific handlers.
|
2017-02-18 03:35:58 +00:00
|
|
|
services.udev.packages = with pkgs; [ usb-modeswitch-data ];
|
2019-05-05 08:23:32 +00:00
|
|
|
|
|
|
|
# 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";
|
2017-02-18 03:35:58 +00:00
|
|
|
};
|
|
|
|
}
|