Skip to content

Commit a22f47c

Browse files
committed
disks: support bios bootloader
1 parent 534f22b commit a22f47c

3 files changed

Lines changed: 35 additions & 11 deletions

File tree

modules/beacon.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ in {
5959
'';
6060
type = types.str;
6161
default = cfg.ip;
62+
defaultText = "config.skarabox.ip";
6263
};
6364

6465
hostname = lib.mkOption {
@@ -93,6 +94,7 @@ in {
9394
If installing on a cloud instance, set this to the port that can ssh into the instance as given by your cloud provider, usually 22.
9495
'';
9596
default = cfg.sshPort;
97+
defaultText = "config.skarabox.sshPort";
9698
};
9799

98100
sshAuthorizedKey = lib.mkOption {
@@ -121,6 +123,7 @@ in {
121123
If installing on a cloud instance, set this to the ssh key that can ssh into the instance as given by your cloud provider.
122124
'';
123125
default = cfg.sshAuthorizedKey;
126+
defaultText = "config.skarabox.sshAuthorizedKey";
124127
apply = readAsListOfStr;
125128
};
126129
};

modules/disks.nix

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ in
4444
'';
4545
example = "100G";
4646
};
47+
48+
bootloader = mkOption {
49+
type = types.enum [ "uefi" "bios" ];
50+
description = ''
51+
What bootloader mode to use.
52+
'';
53+
default = if config.hardware.facter.detected.uefi.supported then "uefi" else "bios";
54+
defaultText = ''if config.hardware.facter.detected.uefi.supported then "uefi" else "bios"'';
55+
example = "bios";
56+
};
4757
};
4858
};
4959
};
@@ -114,6 +124,13 @@ in
114124
content = {
115125
type = "gpt";
116126
partitions = {
127+
zfs = {
128+
size = "100%";
129+
content = {
130+
type = "zfs";
131+
pool = cfg.rootPool.name;
132+
};
133+
};
117134
ESP = {
118135
size = "500M";
119136
type = "EF00";
@@ -131,12 +148,11 @@ in
131148
'';
132149
};
133150
};
134-
zfs = {
135-
size = "100%";
136-
content = {
137-
type = "zfs";
138-
pool = cfg.rootPool.name;
139-
};
151+
} // lib.optionalAttrs (cfg.rootPool.bootloader == "bios") {
152+
boot = {
153+
size = "1M";
154+
type = "EF02";
155+
attributes = [ 0 ];
140156
};
141157
};
142158
};
@@ -353,20 +369,22 @@ in
353369

354370
# Setup Grub to support UEFI.
355371
# nodev is for UEFI.
356-
boot.loader.grub = {
372+
boot.loader.grub = let
373+
isUEFI = cfg.rootPool.bootloader == "uefi";
374+
in {
357375
enable = true;
358-
efiSupport = true;
359-
efiInstallAsRemovable = true;
376+
efiSupport = isUEFI;
377+
efiInstallAsRemovable = isUEFI;
360378

361379
mirroredBoots = lib.mkForce ([
362380
{
363381
path = "/boot";
364-
devices = [ "nodev" ];
382+
devices = if isUEFI then [ "nodev" ] else [ cfg.rootPool.disk1 ];
365383
}
366384
] ++ (optionals (cfg.rootPool.disk2 != null) [
367385
{
368386
path = "/boot-backup";
369-
devices = [ "nodev" ];
387+
devices = if isUEFI then [ "nodev" ] else [ cfg.rootPool.disk2 ];
370388
}
371389
]));
372390
};

template/myskarabox/configuration.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ in
2525
disk1 = "/dev/nvme0n1"; # Update with result of running `fdisk -l` on the beacon.
2626
disk2 = null; # Set a value only if you have a second disk for the root partition.
2727
reservation = "500M"; # Set to 10% of size SSD.
28+
# The bootloader - "uefi" or "bios" - should be detected from the facter.json.
29+
# If the detected value is wrong, you can set it manually with the following option:
30+
# bootloader = "bios";
2831
};
2932
skarabox.disks.dataPool = {
3033
enable = true; # Disable if only an SSD for root is present.

0 commit comments

Comments
 (0)