mirror of
https://github.com/NixOS/nixos-hardware
synced 2024-11-26 21:09:42 +01:00
apple/t2: add tiny-dfr option
This commit is contained in:
parent
ca0662edb0
commit
6f71da566f
1 changed files with 62 additions and 51 deletions
|
@ -49,20 +49,27 @@ let
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options.hardware.apple-t2 = {
|
||||||
hardware.apple-t2.enableAppleSetOsLoader = lib.mkOption {
|
enableAppleSetOsLoader = lib.mkOption {
|
||||||
default = false;
|
default = false;
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
description = "Whether to enable the appleSetOsLoader activation script.";
|
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
|
# For keyboard and touchbar
|
||||||
boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.callPackage ./pkgs/linux-t2.nix { });
|
boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.callPackage ./pkgs/linux-t2.nix { });
|
||||||
boot.initrd.kernelModules = [ "apple-bce" ];
|
boot.initrd.kernelModules = [ "apple-bce" ];
|
||||||
|
|
||||||
services.udev.packages = [ audioFilesUdevRules tiny-dfrPackage ];
|
services.udev.packages = [ audioFilesUdevRules ];
|
||||||
|
|
||||||
# For audio
|
# For audio
|
||||||
boot.kernelParams = [ "pcie_ports=compat" "intel_iommu=on" "iommu=pt" ];
|
boot.kernelParams = [ "pcie_ports=compat" "intel_iommu=on" "iommu=pt" ];
|
||||||
|
@ -74,27 +81,12 @@ in
|
||||||
pipewire = pipewirePackage;
|
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
|
# Make sure post-resume.service exists
|
||||||
powerManagement.enable = true;
|
powerManagement.enable = true;
|
||||||
|
}
|
||||||
|
(lib.mkIf t2Cfg.enableAppleSetOsLoader {
|
||||||
# Activation script to install apple-set-os-loader in order to unlock the iGPU
|
# 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
|
if [[ -e /boot/efi/efi/boot/bootx64_original.efi ]]; then
|
||||||
true # It's already installed, no action required
|
true # It's already installed, no action required
|
||||||
elif [[ -e /boot/efi/efi/boot/bootx64.efi ]]; then
|
elif [[ -e /boot/efi/efi/boot/bootx64.efi ]]; then
|
||||||
|
@ -112,8 +104,27 @@ in
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Enable the iGPU by default if present
|
# 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
|
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";
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue