Skip to content

Commit 47dca15

Browse files
bors[bot]NickCaoDanielSiepmannkekrbydependabot[bot]
authored
630: starfive visionfive2: update kernel to 6.4.0 r=Mic92 a=NickCao 649: macbook-air-6: remove mba6x_bl kernel module r=Mic92 a=DanielSiepmann 650: apple/t2: init r=Mic92 a=networkException 652: build(deps): bump cachix/install-nix-action from 21 to 22 r=Mic92 a=dependabot[bot] 654: fixing iptsd not able to find DEVICE r=Mic92 a=buttergrillcorn 656: treewide: avoid alias usage for intel-vaapi-driver based on nixos version r=Mic92 a=lilyinstarlight 657: Added more blocked Nvidia kernel modules to fix the dGPU not being disabled r=Mic92 a=spacebanana420 Co-authored-by: Nick Cao <[email protected]> Co-authored-by: Daniel Siepmann <[email protected]> Co-authored-by: kekrby <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: buttergrillcorn <[email protected]> Co-authored-by: Lily Foster <[email protected]> Co-authored-by: Space Banana <[email protected]>
8 parents 7dd2063 + ff35653 + 2d54ea3 + 8e28b9e + ba74676 + ef7a267 + 1d0b3cf + 289a5af commit 47dca15

File tree

15 files changed

+204
-25
lines changed

15 files changed

+204
-25
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v3
10-
- uses: cachix/install-nix-action@v21
10+
- uses: cachix/install-nix-action@v22
1111
with:
1212
nix_path: nixpkgs=channel:nixos-unstable
1313
- name: Show nixpkgs version

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ See code for all available configurations.
8080
| [Apple MacBook Pro 11,5](apple/macbook-pro/11-5) | `<nixos-hardware/apple/macbook-pro/11-5>` |
8181
| [Apple MacBook Pro 12,1](apple/macbook-pro/12-1) | `<nixos-hardware/apple/macbook-pro/12-1>` |
8282
| [Apple MacBook Pro 14,1](apple/macbook-pro/14-1) | `<nixos-hardware/apple/macbook-pro/14-1>` |
83+
| [Apple Macs with a T2 Chip](apple/t2) | `<nixos-hardware/apple/t2>` |
8384
| [Asus ROG Strix G733QS](asus/rog-strix/g733qs) | `<nixos-hardware/asus/rog-strix/g733qs>` |
8485
| [Asus ROG Zephyrus G14 GA401](asus/zephyrus/ga401) | `<nixos-hardware/asus/zephyrus/ga401>` |
8586
| [Asus ROG Zephyrus G14 GA402](asus/zephyrus/ga402) | `<nixos-hardware/asus/zephyrus/ga402>` |

apple/macbook-air/6/default.nix

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@
44
imports = [ ../. ];
55

66
boot = {
7-
extraModulePackages = with config.boot.kernelPackages; [ mba6x_bl ];
8-
kernelModules = [ "mba6x_bl" ];
9-
107
# Divides power consumption by two.
118
kernelParams = [ "acpi_osi=" ];
129
};
1310

1411
services.xserver.deviceSection = lib.mkDefault ''
15-
Option "Backlight" "mba6x_backlight"
1612
Option "TearFree" "true"
1713
'';
1814
}

apple/t2/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## NixOS on T2 Macs
2+
3+
This is the `nixos-hardware` module of the [T2 Linux Project](https://t2linux.org).
4+
5+
Overall, most features (WiFi, bluetooth, audio, touchbar, ...) of Macs are supported, [see this page](https://wiki.t2linux.org/state/) for a detailed list of things that work and things that don't/partially work.
6+
7+
Following [this guide](https://wiki.t2linux.org/distributions/nixos/installation/) is the recommended way to install, as it incudes the extra things you have to do on a T2 Mac.
8+
9+
You can consult the [wiki](https://wiki.t2linux.org/) for information specific to T2 Macs.

apple/t2/default.nix

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{ pkgs, ... }:
2+
3+
let
4+
audioFiles = pkgs.fetchFromGitHub {
5+
owner = "kekrby";
6+
repo = "t2-better-audio";
7+
rev = "e46839a28963e2f7d364020518b9dac98236bcae";
8+
hash = "sha256-x7K0qa++P1e1vuCGxnsFxL1d9+nwMtZUJ6Kd9e27TFs=";
9+
};
10+
11+
overrideAudioFiles = package: pluginsPath:
12+
package.overrideAttrs (new: old: {
13+
preConfigurePhases = old.preConfigurePhases or [ ] ++ [ "postPatchPhase" ];
14+
15+
postPatchPhase = ''
16+
cp -r ${audioFiles}/files/{profile-sets,paths} ${pluginsPath}/alsa/mixer/
17+
'';
18+
});
19+
in
20+
{
21+
# For keyboard and touchbar
22+
boot.kernelPackages = with pkgs; recurseIntoAttrs (linuxPackagesFor (callPackage ./pkgs/linux-t2.nix { }));
23+
boot.initrd.kernelModules = [ "apple-bce" ];
24+
25+
# For audio
26+
boot.kernelParams = [ "pcie_ports=compat" "intel_iommu=on" "iommu=pt" ];
27+
services.udev.extraRules = builtins.readFile (pkgs.substitute {
28+
src = "${audioFiles}/files/91-audio-custom.rules";
29+
replacements = [ "--replace" "/usr/bin/sed" "${pkgs.gnused}/bin/sed" ];
30+
});
31+
32+
hardware.pulseaudio.package = overrideAudioFiles pkgs.pulseaudio "src/modules/";
33+
34+
services.pipewire = rec {
35+
package = overrideAudioFiles pkgs.pipewire "spa/plugins/";
36+
37+
wireplumber.package = pkgs.wireplumber.override {
38+
pipewire = package;
39+
};
40+
};
41+
42+
# Make sure post-resume.service exists
43+
powerManagement.enable = true;
44+
45+
systemd.services.fix-keyboard-backlight-and-touchbar = {
46+
path = [ pkgs.kmod ];
47+
serviceConfig.ExecStart = ''${pkgs.systemd}/bin/systemd-inhibit --what=sleep --why="fixing keyboard backlight and touchbar must finish before sleep" --mode=delay ${./fix-keyboard-backlight-and-touchbar.sh}'';
48+
serviceConfig.Type = "oneshot";
49+
description = "reload touchbar driver and restart upower";
50+
# must run at boot (and not too early), and after suspend
51+
wantedBy = [ "display-manager.service" "post-resume.target" ];
52+
# prevent running before suspend
53+
after = [ "post-resume.target" ];
54+
};
55+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
3+
set -eux
4+
5+
unload () {
6+
if modprobe -r "$1" 2>&1;
7+
then echo ok
8+
else echo fail
9+
fi
10+
}
11+
12+
wait_unload() {
13+
while sleep 1; do
14+
output="$(unload "$1")"
15+
case "$output" in
16+
*is\ in\ use*) :;;
17+
*ok*) return 0;;
18+
*) echo "modprobe said: $output"; echo giving up; return 1;
19+
esac
20+
done
21+
}
22+
23+
wait_unload apple_touchbar
24+
modprobe apple_touchbar
25+
26+
# After suspend, the inode for the backlight device has changed. This service
27+
# simply restarts upower to inform it of that change.
28+
systemctl restart upower.service

apple/t2/pkgs/linux-t2.nix

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{ lib, buildLinux, fetchFromGitHub, fetchurl, ... } @ args:
2+
3+
let
4+
patchRepo = fetchFromGitHub {
5+
owner = "t2linux";
6+
repo = "linux-t2-patches";
7+
rev = "c0db79a25bc37dbd0c27636914b3903016a2fc39";
8+
hash = "sha256-VILJAK7F0E/8Z3sOzsUpS9dmtpull2XVXQkakZ0UTIA=";
9+
};
10+
11+
version = "6.4";
12+
majorVersion = with lib; (elemAt (take 1 (splitVersion version)) 0);
13+
in
14+
buildLinux (args // {
15+
inherit version;
16+
17+
pname = "linux-t2";
18+
# Snippet from nixpkgs
19+
modDirVersion = with lib; "${concatStringsSep "." (take 3 (splitVersion "${version}.0"))}";
20+
21+
src = fetchurl {
22+
url = "mirror://kernel/linux/kernel/v${majorVersion}.x/linux-${version}.tar.xz";
23+
hash = "sha256-j6BYjwws7KRMrHeg45ukjJ8AprncaXYcAqXT76yNp/M=";
24+
};
25+
26+
structuredExtraConfig = with lib.kernel; {
27+
APPLE_BCE = module;
28+
APPLE_GMUX = module;
29+
BRCMFMAC = module;
30+
BT_BCM = module;
31+
BT_HCIBCM4377 = module;
32+
BT_HCIUART_BCM = yes;
33+
BT_HCIUART = module;
34+
HID_APPLE_IBRIDGE = module;
35+
HID_APPLE = module;
36+
HID_APPLE_MAGIC_BACKLIGHT = module;
37+
HID_APPLE_TOUCHBAR = module;
38+
HID_SENSOR_ALS = module;
39+
SND_PCM = module;
40+
STAGING = yes;
41+
};
42+
43+
kernelPatches = lib.attrsets.mapAttrsToList (file: type: { name = file; patch = "${patchRepo}/${file}"; })
44+
(lib.attrsets.filterAttrs (file: type: type == "regular" && lib.strings.hasSuffix ".patch" file)
45+
(builtins.readDir patchRepo));
46+
} // (args.argsOverride or {}))

common/gpu/intel/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
};
99

1010
hardware.opengl.extraPackages = with pkgs; [
11-
vaapiIntel
11+
(if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11") then vaapiIntel else intel-vaapi-driver)
1212
libvdpau-va-gl
1313
intel-media-driver
1414
];

common/gpu/nvidia/disable.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
# Remove NVIDIA VGA/3D controller devices
2323
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", ATTR{power/control}="auto", ATTR{remove}="1"
2424
'';
25-
boot.blacklistedKernelModules = lib.mkDefault [ "nouveau" "nvidia" ];
26-
}
25+
boot.blacklistedKernelModules = lib.mkDefault [ "nouveau" "nvidia" "nvidia_drm" "nvidia_modeset" ];
26+
}

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
apple-macbook-pro-11-5 = import ./apple/macbook-pro/11-5;
1414
apple-macbook-pro-12-1 = import ./apple/macbook-pro/12-1;
1515
apple-macbook-pro-14-1 = import ./apple/macbook-pro/14-1;
16+
apple-t2 = import ./apple/t2;
1617
asus-battery = import ./asus/battery.nix;
1718
asus-fx504gd = import ./asus/fx504gd;
1819
asus-rog-strix-g733qs = import ./asus/rog-strix/g733qs;

0 commit comments

Comments
 (0)