Skip to content

Commit 042bbbc

Browse files
committed
config(mcl-disko): Add ext4 primary partition type
1 parent f5d7de7 commit 042bbbc

File tree

7 files changed

+205
-164
lines changed

7 files changed

+205
-164
lines changed

modules/mcl-disko/default.nix

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@
1818
options.mcl.disko = {
1919
enable = mkEnableOption "Enable Module";
2020

21-
legacyBoot = mkOption {
22-
type = types.bool;
23-
default = false;
24-
example = true;
25-
description = "Declare if the configuration is for a Hetzner server or not";
21+
primaryPartitionType = mkOption {
22+
type = types.enum [
23+
"zfs"
24+
"legacyBoot"
25+
"ext4"
26+
];
27+
default = "zfs";
28+
example = "legacyBoot";
29+
description = "Declare the type of the primary partition";
2630
};
2731

2832
swapSize = mkOption {
@@ -140,7 +144,7 @@
140144

141145
config.disko =
142146
let
143-
makePrimaryZfsDisk = import ./primaryZfsPartition.nix;
147+
makePrimaryZfsDisk = import ./primaryPartition;
144148
makeSecondaryZfsDisk = import ./secondaryZfsPartition.nix;
145149

146150
first = builtins.head cfg.disks;
@@ -159,7 +163,7 @@
159163
isSecondary = true;
160164
espSize = cfg.espSize;
161165
swapSize = cfg.swapSize;
162-
legacyBoot = cfg.legacyBoot;
166+
primaryPartitionType = cfg.primaryPartitionType;
163167
poolName = cfg.zpool.name;
164168
}
165169
else
@@ -180,14 +184,15 @@
180184
isSecondary = false;
181185
espSize = cfg.espSize;
182186
swapSize = cfg.swapSize;
183-
legacyBoot = cfg.legacyBoot;
187+
primaryPartitionType = cfg.primaryPartitionType;
184188
poolName = cfg.zpool.name;
185189
};
186190
};
187191
zpool = import ./zpool.nix {
188192
poolName = cfg.zpool.name;
189193
poolMode = cfg.zpool.mode;
190194
poolExtraDatasets = cfg.zpool.extraDatasets;
195+
primaryPartitionType = cfg.primaryPartitionType;
191196
inherit lib;
192197
};
193198
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
lib,
3+
disk,
4+
isSecondary,
5+
espSize,
6+
swapSize,
7+
primaryPartitionType,
8+
poolName,
9+
}:
10+
{
11+
type = "disk";
12+
device = disk;
13+
content = {
14+
type = if primaryPartitionType == "legacyBoot" then "table" else "gpt";
15+
partitions =
16+
if primaryPartitionType == "legacyBoot" then
17+
import ./zfs-legacy-boot.nix
18+
else if primaryPartitionType == "ext4" then
19+
import ./ext4.nix
20+
else
21+
import ./zfs.nix;
22+
}
23+
// lib.optionalAttrs (primaryPartitionType == "legacyBoot") {
24+
format = "gpt";
25+
};
26+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"${disk}" = {
3+
device = "/dev/disk/by-id/${disk}";
4+
type = "disk";
5+
content = {
6+
type = "gpt";
7+
partitions = {
8+
ESP = {
9+
type = "EF00";
10+
size = espSize;
11+
content = {
12+
type = "filesystem";
13+
format = "vfat";
14+
mountpoint = "/boot";
15+
mountOptions = [ "umask=0077" ];
16+
};
17+
};
18+
nixos = {
19+
size = "100%";
20+
content = {
21+
type = "filesystem";
22+
format = "ext4";
23+
mountpoint = "/";
24+
};
25+
};
26+
};
27+
};
28+
};
29+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[
2+
{
3+
name = "boot";
4+
start = "1MiB";
5+
end = "2MiB";
6+
part-type = "primary";
7+
flags = [ "bios_grub" ];
8+
}
9+
{
10+
name = "ESP";
11+
start = "2MiB";
12+
end = espSize;
13+
bootable = true;
14+
content = {
15+
type = "filesystem";
16+
format = "vfat";
17+
mountpoint = if isSecondary then null else "/boot";
18+
};
19+
}
20+
{
21+
name = "zfs";
22+
start = espSize;
23+
end = "-${swapSize}";
24+
part-type = "primary";
25+
content = {
26+
type = "zfs";
27+
pool = "${poolName}";
28+
};
29+
}
30+
{
31+
name = "swap";
32+
start = "-${swapSize}";
33+
end = "100%";
34+
part-type = "primary";
35+
content = {
36+
type = "swap";
37+
randomEncryption = true;
38+
};
39+
}
40+
]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"ESP" = {
3+
device = "${disk}-part1";
4+
size = espSize;
5+
type = "EF00";
6+
content = {
7+
type = "filesystem";
8+
format = "vfat";
9+
mountpoint = if isSecondary then null else "/boot";
10+
mountOptions = [ "umask=0077" ];
11+
};
12+
};
13+
14+
"zfs" = {
15+
device = "${disk}-part2";
16+
end = "-${swapSize}";
17+
type = "BF00";
18+
content = {
19+
type = "zfs";
20+
pool = "${poolName}";
21+
};
22+
};
23+
24+
"swap" = {
25+
device = "${disk}-part3";
26+
size = swapSize;
27+
content = {
28+
type = "swap";
29+
randomEncryption = true;
30+
};
31+
};
32+
}

modules/mcl-disko/primaryZfsPartition.nix

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)