1
0
Fork 0
mirror of https://github.com/NixOS/nixos-hardware synced 2024-10-18 19:07:23 +02:00

apple/t2: add tiny-dfr option

This commit is contained in:
Reid "reidlab 2024-10-10 17:30:57 -07:00 committed by mergify[bot]
parent ca0662edb0
commit 6f71da566f

View file

@ -49,20 +49,27 @@ let
in
{
options = {
hardware.apple-t2.enableAppleSetOsLoader = lib.mkOption {
options.hardware.apple-t2 = {
enableAppleSetOsLoader = lib.mkOption {
default = false;
type = lib.types.bool;
description = "Whether to enable the appleSetOsLoader activation script.";
};
enableTinyDfr = lib.mkOption {
default = true;
type = lib.types.bool;
description = "Whether to enable the tiny-dfr touchbar service.";
};
};
config = {
config = lib.mkMerge [
{
# For keyboard and touchbar
boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.callPackage ./pkgs/linux-t2.nix { });
boot.initrd.kernelModules = [ "apple-bce" ];
services.udev.packages = [ audioFilesUdevRules tiny-dfrPackage ];
services.udev.packages = [ audioFilesUdevRules ];
# For audio
boot.kernelParams = [ "pcie_ports=compat" "intel_iommu=on" "iommu=pt" ];
@ -74,27 +81,12 @@ in
pipewire = pipewirePackage;
};
# For tiny-dfr
systemd.services.tiny-dfr = {
enable = true;
description = "Tiny Apple silicon touch bar daemon";
after = [ "systemd-user-sessions.service" "getty@tty1.service" "plymouth-quit.service" "systemd-logind.service" ];
bindsTo = [ "dev-tiny_dfr_display.device" "dev-tiny_dfr_backlight.device" ];
startLimitIntervalSec = 30;
startLimitBurst = 2;
script = "${tiny-dfrPackage}/bin/tiny-dfr";
restartTriggers = [ tiny-dfrPackage ];
};
environment.etc."tiny-dfr/config.toml" = {
source = "${tiny-dfrPackage}/share/tiny-dfr/config.toml";
};
# Make sure post-resume.service exists
powerManagement.enable = true;
}
(lib.mkIf t2Cfg.enableAppleSetOsLoader {
# Activation script to install apple-set-os-loader in order to unlock the iGPU
system.activationScripts.appleSetOsLoader = lib.optionalString t2Cfg.enableAppleSetOsLoader ''
system.activationScripts.appleSetOsLoader = ''
if [[ -e /boot/efi/efi/boot/bootx64_original.efi ]]; then
true # It's already installed, no action required
elif [[ -e /boot/efi/efi/boot/bootx64.efi ]]; then
@ -112,8 +104,27 @@ in
'';
# Enable the iGPU by default if present
environment.etc."modprobe.d/apple-gmux.conf".text = lib.optionalString t2Cfg.enableAppleSetOsLoader ''
environment.etc."modprobe.d/apple-gmux.conf".text = ''
options apple-gmux force_igd=y
'';
})
(lib.mkIf t2Cfg.enableTinyDfr {
services.udev.packages = [ tiny-dfrPackage ];
systemd.services.tiny-dfr = {
enable = true;
description = "Tiny Apple silicon touch bar daemon";
after = [ "systemd-user-sessions.service" "getty@tty1.service" "plymouth-quit.service" "systemd-logind.service" ];
bindsTo = [ "dev-tiny_dfr_display.device" "dev-tiny_dfr_backlight.device" ];
startLimitIntervalSec = 30;
startLimitBurst = 2;
script = "${tiny-dfrPackage}/bin/tiny-dfr";
restartTriggers = [ tiny-dfrPackage ];
};
environment.etc."tiny-dfr/config.toml" = {
source = "${tiny-dfrPackage}/share/tiny-dfr/config.toml";
};
})
];
}