at 25.11-pre 4.2 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8let 9 cfg = config.services.asusd; 10in 11{ 12 imports = [ 13 (lib.mkRemovedOptionModule 14 [ 15 "services" 16 "asusd" 17 "auraConfig" 18 ] 19 '' 20 This option has been replaced by `services.asusd.auraConfigs' because asusd 21 supports multiple aura devices since version 6.0.0. 22 '' 23 ) 24 ]; 25 26 options = { 27 services.asusd = 28 with lib.types; 29 let 30 configType = submodule ( 31 { text, source, ... }: 32 { 33 options = { 34 text = lib.mkOption { 35 default = null; 36 type = nullOr lines; 37 description = "Text of the file."; 38 }; 39 40 source = lib.mkOption { 41 default = null; 42 type = nullOr path; 43 description = "Path of the source file."; 44 }; 45 }; 46 } 47 ); 48 in 49 { 50 enable = lib.mkEnableOption "the asusd service for ASUS ROG laptops"; 51 52 package = lib.mkPackageOption pkgs "asusctl" { }; 53 54 enableUserService = lib.mkOption { 55 type = bool; 56 default = false; 57 description = '' 58 Activate the asusd-user service. 59 ''; 60 }; 61 62 animeConfig = lib.mkOption { 63 type = nullOr configType; 64 default = null; 65 description = '' 66 The content of /etc/asusd/anime.ron. 67 See <https://asus-linux.org/asusctl/#anime-control>. 68 ''; 69 }; 70 71 asusdConfig = lib.mkOption { 72 type = nullOr configType; 73 default = null; 74 description = '' 75 The content of /etc/asusd/asusd.ron. 76 See <https://asus-linux.org/asusctl/>. 77 ''; 78 }; 79 80 auraConfigs = lib.mkOption { 81 type = attrsOf configType; 82 default = { }; 83 description = '' 84 The content of /etc/asusd/aura_<name>.ron. 85 See <https://asus-linux.org/asusctl/#led-keyboard-control>. 86 ''; 87 }; 88 89 profileConfig = lib.mkOption { 90 type = nullOr configType; 91 default = null; 92 description = '' 93 The content of /etc/asusd/profile.ron. 94 See <https://asus-linux.org/asusctl/#profiles>. 95 ''; 96 }; 97 98 fanCurvesConfig = lib.mkOption { 99 type = nullOr configType; 100 default = null; 101 description = '' 102 The content of /etc/asusd/fan_curves.ron. 103 See <https://asus-linux.org/asusctl/#fan-curves>. 104 ''; 105 }; 106 107 userLedModesConfig = lib.mkOption { 108 type = nullOr configType; 109 default = null; 110 description = '' 111 The content of /etc/asusd/asusd-user-ledmodes.ron. 112 See <https://asus-linux.org/asusctl/#led-keyboard-control>. 113 ''; 114 }; 115 }; 116 }; 117 118 config = lib.mkIf cfg.enable { 119 environment.systemPackages = [ cfg.package ]; 120 121 environment.etc = 122 let 123 maybeConfig = 124 name: cfg: 125 lib.mkIf (cfg != null) ( 126 (if (cfg.source != null) then { source = cfg.source; } else { text = cfg.text; }) 127 // { 128 mode = "0644"; 129 } 130 ); 131 in 132 { 133 "asusd/anime.ron" = maybeConfig "anime.ron" cfg.animeConfig; 134 "asusd/asusd.ron" = maybeConfig "asusd.ron" cfg.asusdConfig; 135 "asusd/profile.ron" = maybeConfig "profile.ron" cfg.profileConfig; 136 "asusd/fan_curves.ron" = maybeConfig "fan_curves.ron" cfg.fanCurvesConfig; 137 "asusd/asusd_user_ledmodes.ron" = maybeConfig "asusd_user_ledmodes.ron" cfg.userLedModesConfig; 138 } 139 // lib.attrsets.concatMapAttrs (prod_id: value: { 140 "asusd/aura_${prod_id}.ron" = maybeConfig "aura_${prod_id}.ron" value; 141 }) cfg.auraConfigs; 142 143 services.dbus.enable = true; 144 systemd.packages = [ cfg.package ]; 145 services.dbus.packages = [ cfg.package ]; 146 services.udev.packages = [ cfg.package ]; 147 services.supergfxd.enable = lib.mkDefault true; 148 149 systemd.user.services.asusd-user.enable = cfg.enableUserService; 150 }; 151 152 meta.maintainers = pkgs.asusctl.meta.maintainers; 153}