Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 341d72a

Browse files
committedJun 5, 2019
macs: build clover.qcow2 ourselves
1 parent 63cb172 commit 341d72a

File tree

6 files changed

+123
-34
lines changed

6 files changed

+123
-34
lines changed
 

‎delft/network.nix

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ let
1818
zvolName = "rpool/mac-hdd-2-initial-setup-startup-script.img";
1919
ovmfCodeFile = ../macs/dist/OVMF_CODE.fd;
2020
ovmfVarsFile = ../macs/dist/OVMF_VARS-1024x768.fd;
21-
cloverImage = ../macs/dist/Clover.qcow2;
2221
guestConfigDir = ../macs/guest;
2322
};
2423
};

‎macs/build.nix

-32
This file was deleted.

‎macs/dist/Clover.qcow2

-6.06 MB
Binary file not shown.

‎macs/dist/config.plist.template

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>Boot</key>
6+
<dict>
7+
<key>Arguments</key>
8+
<string>@params@</string>
9+
<key>DefaultVolume</key>
10+
<string>system</string>
11+
<key>Log</key>
12+
<true/>
13+
<key>Secure</key>
14+
<false/>
15+
<key>Timeout</key>
16+
<integer>@timeout@</integer>
17+
</dict>
18+
<key>GUI</key>
19+
<dict>
20+
<key>Scan</key>
21+
<dict>
22+
<key>Entries</key>
23+
<true/>
24+
<key>Tool</key>
25+
<true/>
26+
</dict>
27+
<key>ScreenResolution</key>
28+
<string>@resolution@</string>
29+
<key>Theme</key>
30+
<string>embedded</string>
31+
</dict>
32+
<key>RtVariables</key>
33+
<dict>
34+
<key>BooterConfig</key>
35+
<string>0x28</string>
36+
<key>CsrActiveConfig</key>
37+
<string>@csrFlag@</string>
38+
</dict>
39+
<key>SMBIOS</key>
40+
<dict>
41+
<key>Trust</key>
42+
<false/>
43+
</dict>
44+
<key>SystemParameters</key>
45+
<dict>
46+
<key>InjectKexts</key>
47+
<false/>
48+
<key>InjectSystemID</key>
49+
<true/>
50+
</dict>
51+
</dict>
52+
</plist>
53+

‎macs/host/clover.qcow2.nix

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{ lib
2+
, runCommand
3+
, fetchurl
4+
, libguestfs
5+
, libguestfs-appliance
6+
, resolution ? "1024x768"
7+
, csrFlag ? "0x3"
8+
, params ? "-v"
9+
, timeout ? "3"
10+
# https://github.com/Clover-EFI-Bootloader/clover/blob/6b8018b1fec958d672951f87cefd8b6cfd5318ac/rEFIt_UEFI/Platform/boot.h#L127-L135
11+
}:
12+
13+
lib.fix (self: {
14+
clover-image = runCommand "clover.qcow2" {
15+
buildInputs = [ libguestfs ];
16+
inherit resolution csrFlag params timeout;
17+
LIBGUESTFS_PATH = libguestfs-appliance;
18+
} ''
19+
export HOME=$NIX_BUILD_TOP
20+
mkdir work
21+
cp --no-preserve=mode ${self.clover-iso} clover.iso
22+
guestfish -a clover.iso -m "/dev/sda:/:norock" <<EOF
23+
copy-out /EFI work
24+
EOF
25+
eval $(guestfish --listen)
26+
guestfish --remote disk-create clover2.img qcow2 256M
27+
guestfish --remote add clover2.img
28+
time guestfish --remote run
29+
guestfish --remote part-init /dev/sda gpt
30+
guestfish --remote part-add /dev/sda p 2048 200000
31+
guestfish --remote -- part-add /dev/sda p 202048 -2048
32+
guestfish --remote part-set-gpt-type /dev/sda 1 C12A7328-F81F-11D2-BA4B-00A0C93EC93B
33+
guestfish --remote part-set-bootable /dev/sda 1 true
34+
guestfish --remote mkfs vfat /dev/sda1 label:EFI
35+
guestfish --remote mkfs vfat /dev/sda2 label:clover
36+
guestfish --remote mount /dev/sda2 /
37+
guestfish --remote mkdir /ESP
38+
guestfish --remote mount /dev/sda1 /ESP
39+
guestfish --remote mkdir /ESP/EFI
40+
guestfish --remote mkdir /ESP/EFI/CLOVER
41+
guestfish --remote copy-in work/EFI/BOOT /ESP/EFI
42+
guestfish --remote copy-in work/EFI/CLOVER/CLOVERX64.efi /ESP/EFI/CLOVER
43+
guestfish --remote copy-in work/EFI/CLOVER/drivers64UEFI /ESP/EFI/CLOVER
44+
guestfish --remote copy-in work/EFI/CLOVER/drivers-Off/drivers64UEFI/PartitionDxe-64.efi /ESP/EFI/CLOVER/drivers64UEFI
45+
guestfish --remote copy-in work/EFI/CLOVER/drivers-Off/drivers64UEFI/ApfsDriverLoader-64.efi /ESP/EFI/CLOVER/drivers64UEFI
46+
guestfish --remote copy-in work/EFI/CLOVER/drivers-Off/drivers64UEFI/OsxAptioFix3Drv-64.efi /ESP/EFI/CLOVER/drivers64UEFI
47+
guestfish --remote copy-in work/EFI/CLOVER/tools /ESP/EFI/CLOVER
48+
substituteAll ${./config.plist.template} work/config.plist
49+
guestfish --remote copy-in work/config.plist /ESP/EFI/CLOVER
50+
guestfish --remote rm /ESP/EFI/CLOVER/drivers64UEFI/AudioDxe-64.efi
51+
guestfish --remote umount-all
52+
guestfish --remote shutdown
53+
mv clover2.img $out
54+
'';
55+
cloverVersion = "4934";
56+
clover-iso-lzma = fetchurl {
57+
url = "mirror://sourceforge/cloverefiboot/CloverISO-${self.cloverVersion}.tar.lzma";
58+
sha256 = "0ivwaapgir2yvsyp7gi9ddj6r97j99n99cz0xwqhcrijimp06hcl";
59+
};
60+
clover-iso = runCommand "clover.iso" {} ''
61+
tar -xvf ${self.clover-iso-lzma}
62+
mv -v *.iso $out
63+
'';
64+
})

‎macs/host/default.nix

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
{ lib, config, ... }:
2+
{ pkgs, lib, config, ... }:
33
let
44
inherit (lib) mkOption types;
55
in {
@@ -197,6 +197,11 @@ in {
197197

198198
cloverImage = mkOption {
199199
type = types.path;
200+
default = pkgs.callPackage ./clover.qcow2.nix {
201+
# 0x23 means allow dtrace and untrusted kexts
202+
# https://github.com/Clover-EFI-Bootloader/clover/blob/6b8018b1fec958d672951f87cefd8b6cfd5318ac/rEFIt_UEFI/Platform/boot.h#L127-L135
203+
csrFlag = "0x23";
204+
};
200205
description = ''
201206
Path to the Clover bootloader.
202207
'';

0 commit comments

Comments
 (0)
Please sign in to comment.