Skip to content

Commit f594982

Browse files
committed
replace clover with opencore
1 parent e5f9f47 commit f594982

1 file changed

Lines changed: 50 additions & 83 deletions

File tree

nix/os/boot.nix

Lines changed: 50 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -91,90 +91,57 @@ in
9191
# Emulate UEFI on BIOS to allow UKI booting
9292
# https://github.com/NixOS/nixpkgs/issues/124132
9393
# https://wiki.archlinux.org/title/Clover#chainload_systemd-boot
94-
(lib.optionalString (boot == "BIOS") ''
95-
clover=${
96-
let
97-
version = "5165";
98-
in
99-
pkgs.fetchzip {
100-
name = "clover-${version}";
101-
url = "https://github.com/CloverHackyColor/CloverBootloader/releases/download/${version}/CloverV2-${version}.zip";
102-
sha256 = "sha256-KbaSQMJWNkBwdFKbYALCTfw0XcL5Cnfb2uIDzLdiLI0=";
94+
(
95+
let
96+
arch = lib.toUpper config.nixpkgs.hostPlatform.efiArch;
97+
in
98+
lib.optionalString (boot == "BIOS") ''
99+
oc=${
100+
let
101+
version = "1.0.6";
102+
in
103+
pkgs.fetchzip {
104+
name = "open-core-${version}";
105+
url = "https://github.com/acidanthera/OpenCorePkg/releases/download/${version}/OpenCore-${version}-RELEASE.zip";
106+
sha256 = lib.fakeHash;
107+
stripRoot = false;
108+
}
103109
}
104-
}
105-
boot0=$clover/BootSectors/boot0af
106-
boot1=$clover/BootSectors/boot1f32
107-
boot2=$clover/Bootloaders/x64/boot7
108-
disks=(${
109-
lib.concatStringsSep " " (map (disk: disk.device) (lib.attrValues config.disko.devices.disk))
110-
})
111-
112-
for disk in "''${disks[@]}"; do
113-
partition="1"
114-
case "$disk" in
115-
*nvme*|*mmcblk*)
116-
part="''${disk}p''${partition}"
117-
;;
118-
*)
119-
part="''${disk}''${partition}"
120-
;;
121-
esac
122-
123-
sgdisk --attributes="''${partition}:set:2" "$disk"
124-
125-
dd if="$boot0" of="$disk" bs=1 count=440 conv=notrunc
126-
127-
cp "$boot1" "$tmp/new_PBR"
128-
dd if="$part" of="$tmp/original_PBR" bs=512 count=1 conv=notrunc
129-
dd if="$tmp/original_PBR" of="$tmp/new_PBR" skip=3 seek=3 bs=1 count=87 conv=notrunc
130-
dd if="$tmp/new_PBR" of="$part" bs=512 count=1 conv=notrunc
131-
rm "$tmp/new_PBR" "$tmp/original_PBR"
132-
done
133-
134-
cp $boot2 "$esp/boot"
135-
mkdir -p "$esp/EFI"
136-
cp -a "$clover/EFI/CLOVER" "$esp/EFI/CLOVER"
137-
cat << EOF > "$esp/EFI/CLOVER/config.plist"
138-
<?xml version="1.0" encoding="UTF-8"?>
139-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd">
140-
<plist version="1.0">
141-
<dict>
142-
<key>Boot</key>
143-
<dict>
144-
<key>DefaultVolume</key>
145-
<string>EFI</string>
146-
<key>DefaultLoader</key>
147-
<string>\EFI\BOOT\BOOT${lib.toUpper config.nixpkgs.hostPlatform.efiArch}.EFI</string>
148-
<key>Fast</key>
149-
<true/>
150-
</dict>
151-
<key>GUI</key>
152-
<dict>
153-
<key>Custom</key>
154-
<dict>
155-
<key>Entries</key>
156-
<array>
157-
<dict>
158-
<key>Hidden</key>
159-
<false/>
160-
<key>Disabled</key>
161-
<false/>
162-
<key>Volume</key>
163-
<string>EFI</string>
164-
<key>Path</key>
165-
<string>\EFI\BOOT\BOOT${lib.toUpper config.nixpkgs.hostPlatform.efiArch}.EFI</string>
166-
<key>Title</key>
167-
<string>XnodeOS</string>
168-
<key>Type</key>
169-
<string>Linux</string>
170-
</dict>
171-
</array>
172-
</dict>
173-
</dict>
174-
</dict>
175-
</plist>
176-
EOF
177-
'')
110+
boot0=$oc/Utilities/LegacyBoot/boot0
111+
boot1=$oc/Utilities/LegacyBoot/boot1f32
112+
boot2=$oc/Utilities/LegacyBoot/boot${arch}
113+
disks=(${
114+
lib.concatStringsSep " " (map (disk: disk.device) (lib.attrValues config.disko.devices.disk))
115+
})
116+
117+
for disk in "''${disks[@]}"; do
118+
partition="1"
119+
case "$disk" in
120+
*nvme*|*mmcblk*)
121+
part="''${disk}p''${partition}"
122+
;;
123+
*)
124+
part="''${disk}''${partition}"
125+
;;
126+
esac
127+
128+
sgdisk --attributes="''${partition}:set:2" "$disk"
129+
130+
dd if="$boot0" of="$disk" bs=1 count=446 conv=notrunc
131+
132+
cp "$boot1" "$tmp/new_PBR"
133+
dd if="$part" of="$tmp/original_PBR" count=1
134+
dd if="$tmp/original_PBR" of="$tmp/new_PBR" skip=3 seek=3 bs=1 count=87 conv=notrunc
135+
dd if=/dev/random of="$tmp/new_PBR" skip=496 seek=496 bs=1 count=14 conv=notrunc
136+
dd if="$tmp/new_PBR" of="$part"
137+
rm "$tmp/new_PBR" "$tmp/original_PBR"
138+
done
139+
140+
cp $boot2 "$esp/boot"
141+
mkdir -p "$esp/EFI"
142+
cp -a "$oc/${arch}/EFI/OC" "$esp/EFI/OC"
143+
''
144+
)
178145
179146
# Update unattended disk decryption lock
180147
(lib.optionalString (tpm == "2") ''

0 commit comments

Comments
 (0)