From dc3ea58abcb6404cdcad082f2ccd9c0d24e56925 Mon Sep 17 00:00:00 2001 From: Alexandre Acebedo Date: Fri, 16 Sep 2022 19:23:46 +0200 Subject: [PATCH 1/5] supergfxctl: init at 5.0.1 --- .../system/supergfxctl/default.nix | 45 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 47 insertions(+) create mode 100644 pkgs/applications/system/supergfxctl/default.nix diff --git a/pkgs/applications/system/supergfxctl/default.nix b/pkgs/applications/system/supergfxctl/default.nix new file mode 100644 index 000000000000..f1a88e39e4e7 --- /dev/null +++ b/pkgs/applications/system/supergfxctl/default.nix @@ -0,0 +1,45 @@ +{ lib +, rustPlatform +, fetchFromGitLab +, pkg-config +, systemd +}: + +rustPlatform.buildRustPackage rec { + pname = "supergfxctl"; + version = "5.0.1"; + + src = fetchFromGitLab { + owner = "asus-linux"; + repo = "supergfxctl"; + rev = version; + hash = "sha256-4q+7F8s6y+oDkBUKIBBsXZ2EtADcChdnjmABjBUnH9k="; + }; + + cargoSha256 = "sha256-nfs9sUq9569qXsC7JYMzrRPdQQm/l4HZANlG7827K8o="; + + postPatch = '' + substituteInPlace data/supergfxd.service --replace /usr/bin/supergfxd $out/bin/supergfxd + substituteInPlace data/99-nvidia-ac.rules --replace /usr/bin/systemctl ${systemd}/bin/systemctl + ''; + + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ systemd ]; + + # upstream doesn't have tests, don't build twice just to find that out + doCheck = false; + + postInstall = '' + install -Dm444 -t $out/lib/udev/rules.d/ data/*.rules + install -Dm444 -t $out/share/dbus-1/system.d/ data/org.supergfxctl.Daemon.conf + install -Dm444 -t $out/lib/systemd/system/ data/supergfxd.service + ''; + + meta = with lib; { + description = "A GPU switching utility, mostly for ASUS laptops"; + homepage = "https://gitlab.com/asus-linux/supergfxctl"; + license = licenses.mpl20; + platforms = [ "x86_64-linux" ]; + maintainers = [ maintainers.k900 ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7f30247a59c4..706d99e74a55 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3330,6 +3330,8 @@ with pkgs; sshs = callPackage ../development/tools/sshs { }; + supergfxctl = callPackage ../applications/system/supergfxctl { }; + titaniumenv = callPackage ../development/mobile/titaniumenv { }; abootimg = callPackage ../development/mobile/abootimg {}; From 8f14c05c504b2f674a274341a0203acf02bd98ca Mon Sep 17 00:00:00 2001 From: Alexandre Acebedo Date: Fri, 16 Sep 2022 19:23:46 +0200 Subject: [PATCH 2/5] nixos/supergfxctl: init --- nixos/modules/module-list.nix | 1 + nixos/modules/services/hardware/supergfxd.nix | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 nixos/modules/services/hardware/supergfxd.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 3d6f1e84ecec..765a532407f7 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -477,6 +477,7 @@ ./services/hardware/sane_extra_backends/brscan5.nix ./services/hardware/sane_extra_backends/dsseries.nix ./services/hardware/spacenavd.nix + ./services/hardware/supergfxd.nix ./services/hardware/tcsd.nix ./services/hardware/tlp.nix ./services/hardware/thinkfan.nix diff --git a/nixos/modules/services/hardware/supergfxd.nix b/nixos/modules/services/hardware/supergfxd.nix new file mode 100644 index 000000000000..abb6bedb98ff --- /dev/null +++ b/nixos/modules/services/hardware/supergfxd.nix @@ -0,0 +1,38 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.services.supergfxd; + ini = pkgs.formats.ini { }; +in +{ + options = { + services.supergfxd = { + enable = lib.mkEnableOption (lib.mdDoc "Enable the supergfxd service"); + + settings = lib.mkOption { + type = lib.types.nullOr ini.type; + default = null; + description = lib.mdDoc '' + The content of /etc/supergfxd.conf. + See https://gitlab.com/asus-linux/supergfxctl/#config-options-etcsupergfxdconf. + ''; + }; + }; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = [ pkgs.supergfxctl ]; + + environment.etc."supergfxd.conf" = lib.mkIf (cfg.settings != null) (ini.generate "supergfxd.conf" cfg.settings); + + services.dbus.enable = true; + + systemd.packages = [ pkgs.supergfxctl ]; + systemd.services.supergfxd.wantedBy = [ "multi-user.target" ]; + + services.dbus.packages = [ pkgs.supergfxctl ]; + services.udev.packages = [ pkgs.supergfxctl ]; + }; + + meta.maintainers = pkgs.supergfxctl.meta.maintainers; +} From ccd434854d60e568962d3cba0a2600a47f99a99b Mon Sep 17 00:00:00 2001 From: Alexandre Acebedo Date: Fri, 16 Sep 2022 19:23:46 +0200 Subject: [PATCH 3/5] asusctl: init at 4.5.2 --- pkgs/applications/system/asusctl/default.nix | 89 ++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 91 insertions(+) create mode 100644 pkgs/applications/system/asusctl/default.nix diff --git a/pkgs/applications/system/asusctl/default.nix b/pkgs/applications/system/asusctl/default.nix new file mode 100644 index 000000000000..8c6330e69fbf --- /dev/null +++ b/pkgs/applications/system/asusctl/default.nix @@ -0,0 +1,89 @@ +{ lib +, rustPlatform +, fetchFromGitLab +, e2fsprogs +, systemd +, coreutils +, pkg-config +, cmake +, fontconfig +, gtk3 +, libappindicator +}: + +rustPlatform.buildRustPackage rec { + pname = "asusctl"; + version = "4.5.2"; + + src = fetchFromGitLab { + owner = "asus-linux"; + repo = "asusctl"; + rev = version; + hash = "sha256-hrmH4DDNzc7iMa5YJUQEb3Ng4QekPG+CoGWoHtv9e58="; + }; + + cargoSha256 = "sha256-7JOy5mKkP021+tx8a579WvmqQewEkjFgcwD/f7gzDt8="; + + postPatch = '' + files=" + daemon/src/config.rs + daemon/src/ctrl_anime/config.rs + daemon-user/src/daemon.rs + daemon-user/src/ctrl_anime.rs + daemon-user/src/user_config.rs + rog-control-center/src/main.rs + " + for file in $files; do + substituteInPlace $file --replace /usr/share $out/share + done + + substituteInPlace daemon/src/ctrl_platform.rs --replace /usr/bin/chattr ${e2fsprogs}/bin/chattr + + substituteInPlace data/asusd.rules --replace systemctl ${systemd}/bin/systemctl + substituteInPlace data/asusd.service \ + --replace /usr/bin/asusd $out/bin/asusd \ + --replace /bin/sleep ${coreutils}/bin/sleep + substituteInPlace data/asusd-user.service \ + --replace /usr/bin/asusd-user $out/bin/asusd-user \ + --replace /usr/bin/sleep ${coreutils}/bin/sleep + ''; + + nativeBuildInputs = [ pkg-config cmake ]; + + buildInputs = [ systemd fontconfig gtk3 ]; + + # upstream has minimal tests, so don't rebuild twice + doCheck = false; + + postInstall = '' + install -Dm444 -t $out/share/dbus-1/system.d/ data/asusd.conf + install -Dm444 -t $out/share/rog-gui/layouts/ rog-aura/data/layouts/* + + install -Dm444 -t $out/share/applications/ rog-control-center/data/rog-control-center.desktop + install -Dm444 -t $out/share/icons/hicolor/512x512/apps/ rog-control-center/data/rog-control-center.png data/icons/asus_notif_* + install -Dm444 -t $out/share/icons/hicolor/scalable/status/ data/icons/scalable/* + + install -Dm444 -t $out/share/asusd/anime/asus/rog/ rog-anime/data/anime/asus/rog/Sunset.gif + install -Dm444 -t $out/share/asusd/anime/asus/gaming/ rog-anime/data/anime/asus/gaming/Controller.gif + install -Dm444 -t $out/share/asusd/anime/custom/ rog-anime/data/anime/custom/* + + install -Dm444 -t $out/share/asusd/data/ data/asusd-ledmodes.toml + + install -Dm444 data/asusd.rules $out/lib/udev/rules.d/99-asusd.rules + install -Dm444 -t $out/share/dbus-1/system.d/ data/asusd.conf + install -Dm444 -t $out/lib/systemd/system/ data/asusd.service + install -Dm444 -t $out/lib/systemd/user/ data/asusd-user.service + ''; + + postFixup = '' + patchelf --add-rpath "${libappindicator}/lib" "$out/bin/rog-control-center" + ''; + + meta = with lib; { + description = "A control daemon, CLI tools, and a collection of crates for interacting with ASUS ROG laptops"; + homepage = "https://gitlab.com/asus-linux/asusctl"; + license = licenses.mpl20; + platforms = [ "x86_64-linux" ]; + maintainers = with maintainers; [ k900 aacebedo ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 706d99e74a55..1b30b5a643af 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2766,6 +2766,8 @@ with pkgs; autoreconfHook = buildPackages.autoreconfHook269; }; + asusctl = callPackage ../applications/system/asusctl { }; + autorevision = callPackage ../tools/misc/autorevision { }; automirror = callPackage ../tools/misc/automirror { }; From 8f7537e34fdaa2d1e0dda57e36a1b93e91449757 Mon Sep 17 00:00:00 2001 From: Alexandre Acebedo Date: Fri, 16 Sep 2022 19:23:46 +0200 Subject: [PATCH 4/5] nixos/asusctl: init --- nixos/modules/module-list.nix | 1 + nixos/modules/services/hardware/asusd.nix | 114 ++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 nixos/modules/services/hardware/asusd.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 765a532407f7..f691d74bfd22 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -450,6 +450,7 @@ ./services/hardware/acpid.nix ./services/hardware/actkbd.nix ./services/hardware/argonone.nix + ./services/hardware/asusd.nix ./services/hardware/auto-cpufreq.nix ./services/hardware/bluetooth.nix ./services/hardware/bolt.nix diff --git a/nixos/modules/services/hardware/asusd.nix b/nixos/modules/services/hardware/asusd.nix new file mode 100644 index 000000000000..f0751c440251 --- /dev/null +++ b/nixos/modules/services/hardware/asusd.nix @@ -0,0 +1,114 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.services.asusd; + json = pkgs.formats.json { }; + toml = pkgs.formats.toml { }; +in +{ + options = { + services.asusd = { + enable = lib.mkEnableOption (lib.mdDoc "the asusd service for ASUS ROG laptops"); + + enableUserService = lib.mkOption { + type = lib.types.bool; + default = false; + description = lib.mdDoc '' + Activate the asusd-user service. + ''; + }; + + animeConfig = lib.mkOption { + type = json.type; + default = { }; + description = lib.mdDoc '' + The content of /etc/asusd/anime.conf. + See https://asus-linux.org/asusctl/#anime-control. + ''; + }; + + asusdConfig = lib.mkOption { + type = json.type; + default = { }; + description = lib.mdDoc '' + The content of /etc/asusd/asusd.conf. + See https://asus-linux.org/asusctl/. + ''; + }; + + auraConfig = lib.mkOption { + type = json.type; + default = { }; + description = lib.mdDoc '' + The content of /etc/asusd/aura.conf. + See https://asus-linux.org/asusctl/#led-keyboard-control. + ''; + }; + + profileConfig = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = ""; + description = lib.mdDoc '' + The content of /etc/asusd/profile.conf. + See https://asus-linux.org/asusctl/#profiles. + ''; + }; + + ledModesConfig = lib.mkOption { + type = lib.types.nullOr toml.type; + default = null; + description = lib.mdDoc '' + The content of /etc/asusd/asusd-ledmodes.toml. Leave `null` to use default settings. + See https://asus-linux.org/asusctl/#led-keyboard-control. + ''; + }; + + userLedModesConfig = lib.mkOption { + type = lib.types.nullOr toml.type; + default = null; + description = lib.mdDoc '' + The content of /etc/asusd/asusd-user-ledmodes.toml. + See https://asus-linux.org/asusctl/#led-keyboard-control. + ''; + }; + }; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = [ pkgs.asusctl ]; + + environment.etc = + let + maybeConfig = name: cfg: lib.mkIf (cfg != { }) { + source = json.generate name cfg; + mode = "0644"; + }; + in + { + "asusd/anime.conf" = maybeConfig "anime.conf" cfg.animeConfig; + "asusd/asusd.conf" = maybeConfig "asusd.conf" cfg.asusdConfig; + "asusd/aura.conf" = maybeConfig "aura.conf" cfg.auraConfig; + "asusd/profile.conf" = lib.mkIf (cfg.profileConfig != null) { + source = pkgs.writeText "profile.conf" cfg.profileConfig; + mode = "0644"; + }; + "asusd/asusd-ledmodes.toml" = { + source = + if cfg.ledModesConfig == null + then "${pkgs.asusctl}/share/asusd/data/asusd-ledmodes.toml" + else toml.generate "asusd-ledmodes.toml" cfg.ledModesConfig; + mode = "0644"; + }; + }; + + services.dbus.enable = true; + systemd.packages = [ pkgs.asusctl ]; + services.dbus.packages = [ pkgs.asusctl ]; + services.udev.packages = [ pkgs.asusctl ]; + services.supergfxd.enable = true; + + systemd.user.services.asusd-user.enable = cfg.enableUserService; + }; + + meta.maintainers = pkgs.asusctl.meta.maintainers; +} From 0905acf06944ac5b6b38723b7b15963213e34df6 Mon Sep 17 00:00:00 2001 From: Alexandre Acebedo Date: Sat, 3 Dec 2022 17:09:28 +0100 Subject: [PATCH 5/5] nixos/rog-control-center: init --- nixos/modules/module-list.nix | 1 + nixos/modules/programs/rog-control-center.nix | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 nixos/modules/programs/rog-control-center.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index f691d74bfd22..f7321904170a 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -211,6 +211,7 @@ ./programs/plotinus.nix ./programs/proxychains.nix ./programs/qt5ct.nix + ./programs/rog-control-center.nix ./programs/rust-motd.nix ./programs/screen.nix ./programs/sedutil.nix diff --git a/nixos/modules/programs/rog-control-center.nix b/nixos/modules/programs/rog-control-center.nix new file mode 100644 index 000000000000..4aef5143ac7f --- /dev/null +++ b/nixos/modules/programs/rog-control-center.nix @@ -0,0 +1,29 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.programs.rog-control-center; +in +{ + options = { + programs.rog-control-center = { + enable = lib.mkEnableOption (lib.mdDoc "the rog-control-center application"); + + autoStart = lib.mkOption { + default = false; + type = lib.types.bool; + description = lib.mdDoc "Whether rog-control-center should be started automatically."; + }; + }; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = [ + pkgs.asusctl + (lib.mkIf cfg.autoStart (pkgs.makeAutostartItem { name = "rog-control-center"; package = pkgs.asusctl; })) + ]; + + services.asusd.enable = true; + }; + + meta.maintainers = pkgs.asusctl.meta.maintainers; +}