1 { config, lib, pkgs, ... }:
3 cfg = config.hardware.logitech;
12 (lib.mkRenamedOptionModule [ "hardware" "logitech" "enable" ] [ "hardware" "logitech" "wireless" "enable" ])
13 (lib.mkRenamedOptionModule [ "hardware" "logitech" "enableGraphical" ] [ "hardware" "logitech" "wireless" "enableGraphical" ])
16 options.hardware.logitech = {
19 enable = lib.mkEnableOption "support for Logitech LCD Devices";
21 startWhenNeeded = lib.mkOption {
22 type = lib.types.bool;
25 Only run the service when an actual supported device is plugged.
29 devices = lib.mkOption {
30 type = lib.types.listOf lib.types.str;
31 default = [ "0a07" "c222" "c225" "c227" "c251" ];
33 List of USB device ids supported by g15daemon.
35 You most likely do not need to change this.
41 enable = lib.mkEnableOption "support for Logitech Wireless Devices";
43 enableGraphical = lib.mkOption {
44 type = lib.types.bool;
46 description = "Enable graphical support applications.";
51 config = lib.mkIf (cfg.wireless.enable || cfg.lcd.enable) {
52 environment.systemPackages = []
53 ++ lib.optional cfg.wireless.enable pkgs.ltunify
54 ++ lib.optional cfg.wireless.enableGraphical pkgs.solaar;
57 # ltunifi and solaar both provide udev rules but the most up-to-date have been split
58 # out into a dedicated derivation
61 ++ lib.optional cfg.wireless.enable pkgs.logitech-udev-rules
62 ++ lib.optional cfg.lcd.enable pkgs.g15daemon;
65 # nixos: hardware.logitech.lcd
66 '' + lib.concatMapStringsSep "\n" (
68 ''ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="${vendor}", ATTRS{idProduct}=="${dev}", TAG+="systemd", ENV{SYSTEMD_WANTS}+="${daemon}.service"''
72 systemd.services."${daemon}" = lib.mkIf cfg.lcd.enable {
73 description = "Logitech LCD Support Daemon";
74 documentation = [ "man:g15daemon(1)" ];
75 wantedBy = lib.mkIf (! cfg.lcd.startWhenNeeded) "multi-user.target";
79 ExecStart = "${pkgs.g15daemon}/bin/g15daemon";
80 # we patch it to write to /run/g15daemon/g15daemon.pid instead of
81 # /run/g15daemon.pid so systemd will do the cleanup for us.
82 PIDFile = "/run/${daemon}/g15daemon.pid";
84 PrivateNetwork = true;
85 ProtectHome = "tmpfs";
86 ProtectSystem = "full"; # strict doesn't work
87 RuntimeDirectory = daemon;
88 Restart = "on-failure";