at 24.11-pre 3.2 kB view raw
1{ config 2, lib 3, pkgs 4, ... 5}: 6with lib; let 7 cfg = config.hardware.uni-sync; 8in 9{ 10 meta.maintainers = with maintainers; [ yunfachi ]; 11 12 options.hardware.uni-sync = { 13 enable = mkEnableOption "udev rules and software for Lian Li Uni Controllers"; 14 package = mkPackageOption pkgs "uni-sync" { }; 15 16 devices = mkOption { 17 default = [ ]; 18 example = literalExpression '' 19 [ 20 { 21 device_id = "VID:1111/PID:11111/SN:1111111111"; 22 sync_rgb = true; 23 channels = [ 24 { 25 mode = "PWM"; 26 } 27 { 28 mode = "Manual"; 29 speed = 100; 30 } 31 { 32 mode = "Manual"; 33 speed = 54; 34 } 35 { 36 mode = "Manual"; 37 speed = 0; 38 } 39 ]; 40 } 41 { 42 device_id = "VID:1010/PID:10101/SN:1010101010"; 43 sync_rgb = false; 44 channels = [ 45 { 46 mode = "Manual"; 47 speed = 0; 48 } 49 ]; 50 } 51 ] 52 ''; 53 description = "List of controllers with their configurations."; 54 type = types.listOf (types.submodule { 55 options = { 56 device_id = mkOption { 57 type = types.str; 58 example = "VID:1111/PID:11111/SN:1111111111"; 59 description = "Unique device ID displayed at each startup."; 60 }; 61 sync_rgb = mkOption { 62 type = types.bool; 63 default = false; 64 example = true; 65 description = "Enable ARGB header sync."; 66 }; 67 channels = mkOption { 68 default = [ ]; 69 example = literalExpression '' 70 [ 71 { 72 mode = "PWM"; 73 } 74 { 75 mode = "Manual"; 76 speed = 100; 77 } 78 { 79 mode = "Manual"; 80 speed = 54; 81 } 82 { 83 mode = "Manual"; 84 speed = 0; 85 } 86 ] 87 ''; 88 description = "List of channels connected to the controller."; 89 type = types.listOf (types.submodule { 90 options = { 91 mode = mkOption { 92 type = types.enum [ "Manual" "PWM" ]; 93 default = "Manual"; 94 example = "PWM"; 95 description = "\"PWM\" to enable PWM sync. \"Manual\" to set speed."; 96 }; 97 speed = mkOption { 98 type = types.int; 99 default = "50"; 100 example = "100"; 101 description = "Fan speed as percentage (clamped between 0 and 100)."; 102 }; 103 }; 104 }); 105 }; 106 }; 107 }); 108 }; 109 }; 110 111 config = mkIf cfg.enable { 112 environment.etc."uni-sync/uni-sync.json".text = mkIf (cfg.devices != [ ]) (builtins.toJSON { configs = cfg.devices; }); 113 114 environment.systemPackages = [ cfg.package ]; 115 services.udev.packages = [ cfg.package ]; 116 }; 117}