about summary refs log tree commit diff
path: root/nixos/modules/hardware
diff options
context:
space:
mode:
authorSandro <sandro.jaeckel@gmail.com>2024-03-30 13:01:37 +0100
committerGitHub <noreply@github.com>2024-03-30 13:01:37 +0100
commit0fb5a30ab4985f7a7ddebb0b33e073952a4fa732 (patch)
tree7d58f25f07fb8891810b7cec432a4ff646e04c09 /nixos/modules/hardware
parentb488f65e713b57a28a5b1fe176a6ef5b3bb64aa0 (diff)
parent05901fbaec6e00f9841f62da4bbd72b68096f763 (diff)
downloadnixlib-0fb5a30ab4985f7a7ddebb0b33e073952a4fa732.tar
nixlib-0fb5a30ab4985f7a7ddebb0b33e073952a4fa732.tar.gz
nixlib-0fb5a30ab4985f7a7ddebb0b33e073952a4fa732.tar.bz2
nixlib-0fb5a30ab4985f7a7ddebb0b33e073952a4fa732.tar.lz
nixlib-0fb5a30ab4985f7a7ddebb0b33e073952a4fa732.tar.xz
nixlib-0fb5a30ab4985f7a7ddebb0b33e073952a4fa732.tar.zst
nixlib-0fb5a30ab4985f7a7ddebb0b33e073952a4fa732.zip
Merge pull request #295236 from yunfachi/init/uni-sync
uni-sync: init at 0.2.0, nixos/uni-sync: init
Diffstat (limited to 'nixos/modules/hardware')
-rw-r--r--nixos/modules/hardware/uni-sync.nix117
1 files changed, 117 insertions, 0 deletions
diff --git a/nixos/modules/hardware/uni-sync.nix b/nixos/modules/hardware/uni-sync.nix
new file mode 100644
index 000000000000..69411619bc94
--- /dev/null
+++ b/nixos/modules/hardware/uni-sync.nix
@@ -0,0 +1,117 @@
+{ config
+, lib
+, pkgs
+, ...
+}:
+with lib; let
+  cfg = config.hardware.uni-sync;
+in
+{
+  meta.maintainers = with maintainers; [ yunfachi ];
+
+  options.hardware.uni-sync = {
+    enable = mkEnableOption (mdDoc "udev rules and software for Lian Li Uni Controllers");
+    package = mkPackageOption pkgs "uni-sync" { };
+
+    devices = mkOption {
+      default = [ ];
+      example = literalExpression ''
+        [
+          {
+            device_id = "VID:1111/PID:11111/SN:1111111111";
+            sync_rgb = true;
+            channels = [
+              {
+                mode = "PWM";
+              }
+              {
+                mode = "Manual";
+                speed = 100;
+              }
+              {
+                mode = "Manual";
+                speed = 54;
+              }
+              {
+                mode = "Manual";
+                speed = 0;
+              }
+            ];
+          }
+          {
+            device_id = "VID:1010/PID:10101/SN:1010101010";
+            sync_rgb = false;
+            channels = [
+              {
+                mode = "Manual";
+                speed = 0;
+              }
+            ];
+          }
+        ]
+      '';
+      description = mdDoc "List of controllers with their configurations.";
+      type = types.listOf (types.submodule {
+        options = {
+          device_id = mkOption {
+            type = types.str;
+            example = "VID:1111/PID:11111/SN:1111111111";
+            description = mdDoc "Unique device ID displayed at each startup.";
+          };
+          sync_rgb = mkOption {
+            type = types.bool;
+            default = false;
+            example = true;
+            description = mdDoc "Enable ARGB header sync.";
+          };
+          channels = mkOption {
+            default = [ ];
+            example = literalExpression ''
+              [
+                {
+                  mode = "PWM";
+                }
+                {
+                  mode = "Manual";
+                  speed = 100;
+                }
+                {
+                  mode = "Manual";
+                  speed = 54;
+                }
+                {
+                  mode = "Manual";
+                  speed = 0;
+                }
+              ]
+            '';
+            description = mdDoc "List of channels connected to the controller.";
+            type = types.listOf (types.submodule {
+              options = {
+                mode = mkOption {
+                  type = types.enum [ "Manual" "PWM" ];
+                  default = "Manual";
+                  example = "PWM";
+                  description = mdDoc "\"PWM\" to enable PWM sync. \"Manual\" to set speed.";
+                };
+                speed = mkOption {
+                  type = types.int;
+                  default = "50";
+                  example = "100";
+                  description = mdDoc "Fan speed as percentage (clamped between 0 and 100).";
+                };
+              };
+            });
+          };
+        };
+      });
+    };
+  };
+
+  config = mkIf cfg.enable {
+    environment.etc."uni-sync/uni-sync.json".text = mkIf (cfg.devices != [ ]) (builtins.toJSON { configs = cfg.devices; });
+
+    environment.systemPackages = [ cfg.package ];
+    services.udev.packages = [ cfg.package ];
+  };
+}