diff --git a/nixos/boot/opencore.nix b/nixos/boot/opencore.nix index aa5d7be..a84bc13 100644 --- a/nixos/boot/opencore.nix +++ b/nixos/boot/opencore.nix @@ -9,6 +9,61 @@ let overlays = [ inputs.oceanix.overlays.default ]; }; + mkKext = + { + pname, + version, + url, + sha256, + }: + pkgs.stdenv.mkDerivation { + inherit pname version; + src = pkgs.fetchurl { inherit url sha256; }; + nativeBuildInputs = [ pkgs.unzip ]; + sourceRoot = "."; + installPhase = '' + runHook preInstall + mkdir -p $out/Kexts + cp -r *.kext $out/Kexts/ + runHook postInstall + ''; + }; + + amfipass = mkKext { + pname = "amfipass"; + version = "1.4.1"; + url = "https://github.com/bluppus20/AMFIPass/releases/download/1.4.1/AMFIPass-v1.4.1-RELEASE.zip"; + sha256 = "07lnvh585y0p8kw6byn1ij42iskkn7xkhy9sn7s43nq6b4a6dch7"; + }; + + cryptexfixup = mkKext { + pname = "cryptexfixup"; + version = "1.0.2"; + url = "https://github.com/acidanthera/CryptexFixup/releases/download/1.0.2/CryptexFixup-1.0.2-RELEASE.zip"; + sha256 = "0pdh02gcxgndadzsllmmncpy2ipnzk8n97hdkylx1lcvfjafbiim"; + }; + + restrictevents = mkKext { + pname = "restrictevents"; + version = "1.1.3"; + url = "https://github.com/acidanthera/RestrictEvents/releases/download/1.1.3/RestrictEvents-1.1.3-RELEASE.zip"; + sha256 = "1s18k25hpbxg59rwpgiwr5p7ci70fzbp99f93lap5a77yl9rbj2l"; + }; + + voodoops2 = mkKext { + pname = "voodoops2controller"; + version = "2.3.6"; + url = "https://github.com/acidanthera/VoodooPS2/releases/download/2.3.6/VoodooPS2Controller-2.3.6-RELEASE.zip"; + sha256 = "sha256-N15qzXc12ZPjLNpmqEklVPtfSRKss1LEPU6uPLByANk="; + }; + + airportitlwm = mkKext { + pname = "airportitlwm"; + version = "2.3.0"; + url = "https://github.com/OpenIntelWireless/itlwm/releases/download/v2.3.0/AirportItlwm_v2.3.0_stable_Sonoma14.4.kext.zip"; + sha256 = "sha256-fvEqgDfrm8eVgow0j0+gcouK3leqCYSwN4Fu+RwtURk="; + }; + ocResources = pkgs.fetchzip { url = "https://github.com/acidanthera/OcBinaryData/archive/refs/heads/master.zip"; sha256 = "sha256-B5CABp0Y2dAVuw7185suaUuryl3iII4QNBVBttivQ7Y="; @@ -20,7 +75,71 @@ let ( { ... }: { + # Register kext packages so they get copied into the EFI intermediate package + # and auto-discovered by mkKexts + oceanix.opencore.resources.packages = [ + oceanixPkgs."lilu-latest-release" + oceanixPkgs."virtualsmc-latest-release" + oceanixPkgs."whatevergreen-latest-release" + oceanixPkgs."applealc-latest-release" + oceanixPkgs."intel-mausi-latest-release" + voodoops2 + airportitlwm + amfipass + cryptexfixup + restrictevents + ]; + oceanix.opencore.settings = { + Kernel.Add."Lilu.kext".Enabled = true; + Kernel.Add."VirtualSMC.kext".Enabled = true; + Kernel.Add."SMCBatteryManager.kext".Enabled = true; + Kernel.Add."SMCProcessor.kext".Enabled = true; + Kernel.Add."WhateverGreen.kext".Enabled = true; + Kernel.Add."AppleALC.kext".Enabled = true; + Kernel.Add."IntelMausi.kext".Enabled = true; + Kernel.Add."VoodooPS2Controller.kext".Enabled = true; + Kernel.Add."AirportItlwm.kext".Enabled = true; + Kernel.Add."AMFIPass.kext".Enabled = true; + Kernel.Add."CryptexFixup.kext".Enabled = true; + Kernel.Add."RestrictEvents.kext".Enabled = true; + + Kernel.Quirks = { + AppleCpuPmCfgLock = true; + AppleXcpmCfgLock = true; + DisableIoMapper = true; + LapicKernelPanic = false; + PanicNoKextDump = true; + PowerTimeoutKernelPanic = true; + XhciPortLimit = false; + }; + + Booter.Quirks = { + AvoidRuntimeDefrag = true; + EnableSafeModeSlide = true; + EnableWriteUnprotector = true; + ProvideCustomSlide = true; + RebuildAppleMemoryMap = true; + SetupVirtualMap = true; + SyncRuntimePermissions = true; + }; + + DeviceProperties.Add."PciRoot(0x0)/Pci(0x2,0x0)" = { + "AAPL,ig-platform-id" = "03006601"; + "device-id" = "66010000"; + }; + + # nvram + NVRAM.Add."7C436110-AB2A-4BBB-A880-FE41995C9F82" = { + # ipc_control_port_options=0 + # amfi_get_out_of_my_way=0x1 + # revpatch=sbvmm,f16c + # revblock=media + "boot-args" = + "ipc_control_port_options=0 amfi_get_out_of_my_way=0x1 -no-compat-check revpatch=sbvmm,f16c revblock=media"; + "csr-active-config" = pkgs.lib.mkForce "AwgAAA=="; + }; + UEFI.Output.ProvideConsoleGop = true; UEFI.Output.Resolution = "1366x768"; UEFI.Output.TextRenderer = "BuiltinGraphics"; @@ -56,7 +175,7 @@ let Misc.Boot.PickerVariant = "Acidanthera\\Syrah"; Misc.Boot.PickerAttributes = 144; Misc.Boot.Timeout = 15; - Misc.Boot.HideAuxiliary = true; + Misc.Boot.HideAuxiliary = false; Misc.Debug = { AppleDebug = true; @@ -71,30 +190,24 @@ let Misc.Security.Vault = "Optional"; UEFI.Quirks.DisableSecurityPolicy = true; UEFI.Quirks.ReleaseUsbOwnership = true; + UEFI.Quirks.RequestBootVarRouting = true; + # spoofer PlatformInfo.Automatic = true; PlatformInfo.UpdateSMBIOSMode = "Create"; PlatformInfo.Generic = { - SystemProductName = "MacBookPro9,2"; - SystemSerialNumber = "C02J19YCDTY3"; - SystemUUID = "8FF32D62-EC2E-46D1-A6D3-D1A5748F5F7B"; - MLB = "C02227802QXF1YJ1M"; + SystemProductName = "MacBookPro10,2"; + SystemSerialNumber = "C02J603FDR53"; + SystemUUID = "2B8E7220-2B6A-4595-B254-930EE04E752A"; + MLB = "C02232403J9F16P1F"; + ROM = "F0B0E7AC067D"; }; - UEFI.Drivers = { - "OpenRuntime.efi" = { - Enabled = true; - }; - "OpenCanopy.efi" = { - Enabled = true; - }; - "OpenLinuxBoot.efi" = { - Enabled = true; - }; - "AudioDxe.efi" = { - Enabled = true; - }; - }; + UEFI.Drivers."OpenRuntime.efi".Enabled = true; + UEFI.Drivers."OpenCanopy.efi".Enabled = true; + UEFI.Drivers."OpenLinuxBoot.efi".Enabled = true; + UEFI.Drivers."AudioDxe.efi".Enabled = true; + Misc.Entries = [ ]; }; } @@ -106,7 +219,7 @@ in { system.activationScripts.opencoreConfig = { text = '' - echo "--- Kopurando In1t ---" + echo "--- Kopurando In1t ---" if [ ! -d "${ocPath}" ] || ! ${pkgs.diffutils}/bin/diff -r "${ocConfig.efiPackage}/EFI/OC" "${ocPath}" >/dev/null 2>&1; then echo "diffs are detected, writing EFI files..." @@ -127,7 +240,7 @@ in if ! ${pkgs.efibootmgr}/bin/efibootmgr | ${pkgs.gnugrep}/bin/grep -q "OpenCore_Copland"; then echo "Registering OpenCore on $TARGET_DISK (partition $PART_NUM)..." - ${pkgs.efibootmgr}/bin/efibootmgr -c -d "$TARGET_DISK" -p "$PART_NUM" -L "OpenCore_Copland" -l "\EFI\OC\OpenCore.efi" + ${pkgs.efibootmgr}/bin/efibootmgr -c -d "$TARGET_DISK" -p "$PART_NUM" -L "OpenCore_Copland" -l "\\EFI\\OC\\OpenCore.efi" fi else echo "Error: Could not find mount point for /boot!"