Skip to content

Commit

Permalink
asusd: Support for multiple aura device configs (#348226)
Browse files Browse the repository at this point in the history
  • Loading branch information
K900 authored Dec 26, 2024
2 parents eb549f0 + 3d2a98c commit 0353967
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 64 deletions.
6 changes: 6 additions & 0 deletions nixos/doc/manual/release-notes/rl-2505.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@

- `ps3-disc-dumper` was updated to 4.2.5, which removed the CLI project and now exclusively offers the GUI

- `asusd` has been upgraded to version 6 which supports multiple aura devices. To account for this, the single `auraConfig` configuration option has been replaced with `auraConfigs` which is an attribute set of config options per each device. The config files may also be now specified as either source files or text strings; to account for this you will need to specify that `text` is used for your existing configs, e.g.:
```diff
-services.asusd.asusdConfig = '''file contents'''
+services.asusd.asusdConfig.text = '''file contents'''
```

- `timescaledb` requires manual upgrade steps.
After you run ALTER EXTENSION, you must run [this SQL script](https://github.com/timescale/timescaledb-extras/blob/master/utils/2.15.X-fix_hypertable_foreign_keys.sql). For more details, see the following pull requests [#6797](https://github.com/timescale/timescaledb/pull/6797).
PostgreSQL 13 is no longer supported in TimescaleDB v2.16.
Expand Down
168 changes: 104 additions & 64 deletions nixos/modules/services/hardware/asusd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,74 +9,110 @@ let
cfg = config.services.asusd;
in
{
imports = [
(lib.mkRemovedOptionModule
[
"services"
"asusd"
"auraConfig"
]
''
This option has been replaced by `services.asusd.auraConfigs' because asusd
supports multiple aura devices since version 6.0.0.
''
)
];

options = {
services.asusd = {
enable = lib.mkEnableOption "the asusd service for ASUS ROG laptops";
services.asusd =
with lib.types;
let
configType = submodule (
{ text, source, ... }:
{
options = {
text = lib.mkOption {
default = null;
type = nullOr lines;
description = "Text of the file.";
};

package = lib.mkPackageOption pkgs "asusctl" { };
source = lib.mkOption {
default = null;
type = nullOr path;
description = "Path of the source file.";
};
};
}
);
in
{
enable = lib.mkEnableOption "the asusd service for ASUS ROG laptops";

enableUserService = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Activate the asusd-user service.
'';
};
package = lib.mkPackageOption pkgs "asusctl" { };

animeConfig = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
The content of /etc/asusd/anime.ron.
See https://asus-linux.org/asusctl/#anime-control.
'';
};
enableUserService = lib.mkOption {
type = bool;
default = false;
description = ''
Activate the asusd-user service.
'';
};

asusdConfig = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
The content of /etc/asusd/asusd.ron.
See https://asus-linux.org/asusctl/.
'';
};
animeConfig = lib.mkOption {
type = nullOr configType;
default = null;
description = ''
The content of /etc/asusd/anime.ron.
See https://asus-linux.org/asusctl/#anime-control.
'';
};

auraConfig = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
The content of /etc/asusd/aura.ron.
See https://asus-linux.org/asusctl/#led-keyboard-control.
'';
};
asusdConfig = lib.mkOption {
type = nullOr configType;
default = null;
description = ''
The content of /etc/asusd/asusd.ron.
See https://asus-linux.org/asusctl/.
'';
};

profileConfig = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
The content of /etc/asusd/profile.ron.
See https://asus-linux.org/asusctl/#profiles.
'';
};
auraConfigs = lib.mkOption {
type = attrsOf configType;
default = { };
description = ''
The content of /etc/asusd/aura_<name>.ron.
See https://asus-linux.org/asusctl/#led-keyboard-control.
'';
};

fanCurvesConfig = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
The content of /etc/asusd/fan_curves.ron.
See https://asus-linux.org/asusctl/#fan-curves.
'';
};
profileConfig = lib.mkOption {
type = nullOr configType;
default = null;
description = ''
The content of /etc/asusd/profile.ron.
See https://asus-linux.org/asusctl/#profiles.
'';
};

fanCurvesConfig = lib.mkOption {
type = nullOr configType;
default = null;
description = ''
The content of /etc/asusd/fan_curves.ron.
See https://asus-linux.org/asusctl/#fan-curves.
'';
};

userLedModesConfig = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
The content of /etc/asusd/asusd-user-ledmodes.ron.
See https://asus-linux.org/asusctl/#led-keyboard-control.
'';
userLedModesConfig = lib.mkOption {
type = nullOr configType;
default = null;
description = ''
The content of /etc/asusd/asusd-user-ledmodes.ron.
See https://asus-linux.org/asusctl/#led-keyboard-control.
'';
};
};
};
};

config = lib.mkIf cfg.enable {
Expand All @@ -86,19 +122,23 @@ in
let
maybeConfig =
name: cfg:
lib.mkIf (cfg != null) {
source = pkgs.writeText name cfg;
mode = "0644";
};
lib.mkIf (cfg != null) (
(if (cfg.source != null) then { source = cfg.source; } else { text = cfg.text; })
// {
mode = "0644";
}
);
in
{
"asusd/anime.ron" = maybeConfig "anime.ron" cfg.animeConfig;
"asusd/asusd.ron" = maybeConfig "asusd.ron" cfg.asusdConfig;
"asusd/aura.ron" = maybeConfig "aura.ron" cfg.auraConfig;
"asusd/profile.ron" = maybeConfig "profile.ron" cfg.profileConfig;
"asusd/fan_curves.ron" = maybeConfig "fan_curves.ron" cfg.fanCurvesConfig;
"asusd/asusd_user_ledmodes.ron" = maybeConfig "asusd_user_ledmodes.ron" cfg.userLedModesConfig;
};
}
// lib.attrsets.concatMapAttrs (prod_id: value: {
"asusd/aura_${prod_id}.ron" = maybeConfig "aura_${prod_id}.ron" value;
}) cfg.auraConfigs;

services.dbus.enable = true;
systemd.packages = [ cfg.package ];
Expand Down

0 comments on commit 0353967

Please sign in to comment.