From 7c309898bcac42058a4e80e7f8bb69436cefb265 Mon Sep 17 00:00:00 2001 From: MinerSebas Date: Thu, 20 Jul 2023 22:20:33 +0200 Subject: nixos/usb-modeswitch: Rename module from usbWwan --- nixos/modules/hardware/usb-modeswitch.nix | 46 +++++++++++++++++++++++++++++++ nixos/modules/hardware/usb-wwan.nix | 39 -------------------------- 2 files changed, 46 insertions(+), 39 deletions(-) create mode 100644 nixos/modules/hardware/usb-modeswitch.nix delete mode 100644 nixos/modules/hardware/usb-wwan.nix (limited to 'nixos/modules/hardware') diff --git a/nixos/modules/hardware/usb-modeswitch.nix b/nixos/modules/hardware/usb-modeswitch.nix new file mode 100644 index 0000000000000..773891b0032f2 --- /dev/null +++ b/nixos/modules/hardware/usb-modeswitch.nix @@ -0,0 +1,46 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + ###### interface + + options = { + + hardware.usb-modeswitch = { + enable = mkOption { + type = types.bool; + default = false; + description = lib.mdDoc '' + 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. + ''; + }; + }; + }; + + ###### implementation + + imports = [ + (mkRenamedOptionModule ["hardware" "usbWwan" ] ["hardware" "usb-modeswitch" ]) + ]; + + config = mkIf config.hardware.usb-modeswitch.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"; + }; +} diff --git a/nixos/modules/hardware/usb-wwan.nix b/nixos/modules/hardware/usb-wwan.nix deleted file mode 100644 index 69673872cf9b7..0000000000000 --- a/nixos/modules/hardware/usb-wwan.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ 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"; - }; -} -- cgit 1.4.1