mirror of
https://github.com/NixOS/nixos-hardware.git
synced 2025-11-10 08:41:03 +01:00
Refactors the kernel package to a generic one and adds support for the lts kernel. Since nixpkgs' kernel packages provide the `kernelPatches` override, utilizing that ensures that kernel updates are not delayed too much due to having to PR them to nixos-hardware separately. This comes at the expense of possible breakage when upstream updates something that breaks the patches. Because the T2 Linux project has a lot of patches which changes periodically, including them in the repository directly is a maintenance burden. Instead, this patch comes with an update script and JSON files containing all of the patches to be downloaded (by fetchurl) and applied. The NixOS option to enable changing release versions will be added in the next commit.
77 lines
2.7 KiB
Nix
77 lines
2.7 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
audioFiles = pkgs.fetchFromGitHub {
|
|
owner = "kekrby";
|
|
repo = "t2-better-audio";
|
|
rev = "e46839a28963e2f7d364020518b9dac98236bcae";
|
|
hash = "sha256-x7K0qa++P1e1vuCGxnsFxL1d9+nwMtZUJ6Kd9e27TFs=";
|
|
};
|
|
|
|
audioFilesUdevRules = pkgs.runCommand "audio-files-udev-rules" {} ''
|
|
mkdir -p $out/lib/udev/rules.d
|
|
cp ${audioFiles}/files/*.rules $out/lib/udev/rules.d
|
|
substituteInPlace $out/lib/udev/rules.d/*.rules --replace "/usr/bin/sed" "${pkgs.gnused}/bin/sed"
|
|
'';
|
|
|
|
overrideAudioFiles = package: pluginsPath:
|
|
package.overrideAttrs (new: old: {
|
|
preConfigurePhases = old.preConfigurePhases or [ ] ++ [ "postPatchPhase" ];
|
|
postPatchPhase = ''
|
|
cp -r ${audioFiles}/files/{profile-sets,paths} ${pluginsPath}/alsa/mixer/
|
|
'';
|
|
});
|
|
|
|
pipewirePackage = overrideAudioFiles pkgs.pipewire "spa/plugins/";
|
|
|
|
t2Cfg = config.hardware.apple-t2;
|
|
|
|
in
|
|
{
|
|
imports = [
|
|
(lib.mkRemovedOptionModule ["hardware" "apple-t2" "enableTinyDfr"] ''
|
|
The hardware.apple-t2.enableTinyDfr option was deprecated and removed since upstream Nixpkgs now has an identical module.
|
|
Please migrate to hardware.apple.touchBar.
|
|
'')
|
|
|
|
(lib.mkRemovedOptionModule ["hardware" "apple-t2" "enableAppleSetOsLoader"] ''
|
|
The hardware.apple-t2.enableAppleSetOsLoader option was removed as the apple_set_os functionality was integrated into the kernel.
|
|
Please uninstall the loader by replacing /esp/EFI/BOOTX64.EFI with /esp/EFI/BOOTX64_original.EFI, where esp is the EFI partition mount point.
|
|
|
|
If you have a device with an AMD dGPU and would like to keep using the iGPU, please set hardware.apple-t2.enableIGPU to true.
|
|
'')
|
|
];
|
|
options.hardware.apple-t2 = {
|
|
enableIGPU = lib.mkEnableOption "the usage of the iGPU on specific Apple devices with an AMD dGPU";
|
|
};
|
|
|
|
config = lib.mkMerge [
|
|
{
|
|
# For keyboard, touchpad, touchbar and audio.
|
|
boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.callPackage ./pkgs/linux-t2 { });
|
|
boot.initrd.kernelModules = [ "apple-bce" ];
|
|
|
|
services.udev.packages = [ audioFilesUdevRules ];
|
|
|
|
# For audio
|
|
boot.kernelParams = [ "pcie_ports=compat" "intel_iommu=on" "iommu=pt" ];
|
|
|
|
hardware.pulseaudio.package = overrideAudioFiles pkgs.pulseaudio "src/modules/";
|
|
|
|
services.pipewire.package = pipewirePackage;
|
|
services.pipewire.wireplumber.package = pkgs.wireplumber.override {
|
|
pipewire = pipewirePackage;
|
|
};
|
|
|
|
# Make sure post-resume.service exists
|
|
powerManagement.enable = true;
|
|
}
|
|
(lib.mkIf t2Cfg.enableIGPU {
|
|
# Enable the iGPU by default if present
|
|
environment.etc."modprobe.d/apple-gmux.conf".text = ''
|
|
options apple-gmux force_igd=y
|
|
'';
|
|
})
|
|
];
|
|
}
|