-
-
Notifications
You must be signed in to change notification settings - Fork 727
/
Copy pathdefault.nix
128 lines (112 loc) · 3.94 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
{
config,
lib,
pkgs,
...
}:
let
inherit (lib) types;
nixosVersion = lib.versions.majorMinor lib.version;
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";
kernelChannel = lib.mkOption {
type = types.enum [
"stable"
"latest"
];
default = "stable";
example = "latest";
description = "The kernel release stream to use.";
};
firmware = {
enable = lib.mkEnableOption "automatic and declarative Wi-Fi and Bluetooth firmware configuration";
version = lib.mkOption {
type = types.enum [
"monterey"
"ventura"
"sonoma"
];
default = "sonoma";
example = "ventura";
description = "The macOS version to use.";
};
};
};
config = lib.mkMerge [
{
# Specialized kernel for keyboard, touchpad, touchbar and audio.
boot.kernelPackages = pkgs.linuxPackagesFor (
pkgs.callPackage (
if t2Cfg.kernelChannel == "stable" then ./pkgs/linux-t2 else ./pkgs/linux-t2/latest.nix
) { }
);
boot.initrd.kernelModules = [ "apple-bce" ];
services.udev.packages = [ audioFilesUdevRules ];
# For audio
boot.kernelParams = [
"pcie_ports=compat"
"intel_iommu=on"
"iommu=pt"
];
services.pipewire.package = pipewirePackage;
services.pipewire.wireplumber.package = pkgs.wireplumber.override {
pipewire = pipewirePackage;
};
# Make sure post-resume.service exists
powerManagement.enable = true;
}
(if lib.versionAtLeast nixosVersion "25.05" then {
services.pulseaudio.package = overrideAudioFiles pkgs.pulseaudio "src/modules/";
} else {
hardware.pulseaudio.package = overrideAudioFiles pkgs.pulseaudio "src/modules/";
})
(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
'';
})
(lib.mkIf t2Cfg.firmware.enable {
# Configure Wi-Fi and Bluetooth firmware
hardware.firmware = [
(pkgs.callPackage ./pkgs/brcm-firmware { version = t2Cfg.firmware.version; })
];
})
];
}