Skip to content

Commit

Permalink
feat: integrate into t2 module
Browse files Browse the repository at this point in the history
  • Loading branch information
osandell committed Aug 9, 2023
1 parent 85517f7 commit 8420d05
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 51 deletions.
9 changes: 3 additions & 6 deletions apple/t2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You can consult the [wiki](https://wiki.t2linux.org/) for information specific t

## Unlocking Internal iGPU

The `apple-set-os-loader-installer.nix` module serves as an installer for the [`apple-set-os-loader`](https://github.com/Redecorating/apple_set_os-loader). This tool is designed to unlock the internal integrated GPU (iGPU) on certain MacBooks. See https://wiki.t2linux.org/guides/hybrid-graphics/ for more details.
The `apple-set-os-loader-installer` module serves as an installer for the [`apple-set-os-loader`](https://github.com/Redecorating/apple_set_os-loader). This tool is designed to unlock the internal integrated GPU (iGPU) on certain MacBooks. See https://wiki.t2linux.org/guides/hybrid-graphics/ for more details.

### What it Does:

Expand All @@ -22,12 +22,9 @@ Upon activation, this module performs the following:

### How to Implement:

1. **Integrate the apple-set-os-loader installer** into your `configuration.nix`:
1. Add this into your `configuration.nix`:
```
imports = [
...
"${builtins.fetchGit { url = "https://github.com/NixOS/nixos-hardware.git"; }}/apple/t2/apple-set-os-loader-installer.nix"
];
hardware.t2.appleSetOsLoader.enable = true;
```

2. **Rebuild your system**:
Expand Down
41 changes: 0 additions & 41 deletions apple/t2/apple-set-os-loader-installer.nix

This file was deleted.

54 changes: 50 additions & 4 deletions apple/t2/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, ... }:
{ pkgs, config, lib, ... }:

let
audioFiles = pkgs.fetchFromGitHub {
Expand All @@ -16,13 +16,59 @@ let
cp -r ${audioFiles}/files/{profile-sets,paths} ${pluginsPath}/alsa/mixer/
'';
});

apple-set-os-loader-installer = pkgs.stdenv.mkDerivation rec {
name = "apple-set-os-loader-installer-1.0";
src = pkgs.fetchFromGitHub {
owner = "Redecorating";
repo = "apple_set_os-loader";
rev = "r33.9856dc4";
sha256 = "hvwqfoF989PfDRrwU0BMi69nFjPeOmSaD6vR6jIRK2Y=";
};
buildInputs = [ pkgs.gnu-efi ];
buildPhase = ''
substituteInPlace Makefile --replace "/usr" '$(GNU_EFI)'
export GNU_EFI=${pkgs.gnu-efi}
make
'';
installPhase = ''
install -D bootx64_silent.efi $out/bootx64.efi
'';
};
in
{
# For keyboard and touchbar
options.hardware.t2.appleSetOsLoader.enable = {
type = lib.types.bool;
default = false;
description = "Enable the apple_set_os-loader";
};

config = lib.mkIf config.hardware.t2.appleSetOsLoader.enable {
system.activationScripts.apple-set-os-loader-installer = {
text = ''
if [[ -e /boot/efi/EFI/BOOT/bootx64_original.efi ]]; then
# Interpret this as apple-set-os-loader being already installed
exit 0
elif [[ -e /boot/efi/EFI/BOOT/BOOTX64.EFI ]] then
mv /boot/efi/EFI/BOOT/BOOTX64.EFI /boot/efi/EFI/BOOT/bootx64_original.efi
cp ${apple-set-os-loader-installer}/bootx64.efi /boot/efi/EFI/BOOT/bootx64.efi
else
echo "Error: /boot/efi/EFI/BOOT/BOOTX64.EFI is missing"
fi
'';
};

environment.etc."modprobe.d/apple-gmux.conf".text =
''
# Enable the iGPU by default if present
options apple-gmux force_igd=y
'';

environment.systemPackages = with pkgs; [ apple-set-os-loader-installer ];
};

boot.kernelPackages = with pkgs; recurseIntoAttrs (linuxPackagesFor (callPackage ./pkgs/linux-t2.nix { }));
boot.initrd.kernelModules = [ "apple-bce" ];

# For audio
boot.kernelParams = [ "pcie_ports=compat" "intel_iommu=on" "iommu=pt" ];
services.udev.extraRules = builtins.readFile (pkgs.substitute {
src = "${audioFiles}/files/91-audio-custom.rules";
Expand Down

0 comments on commit 8420d05

Please sign in to comment.