File tree Expand file tree Collapse file tree 7 files changed +205
-163
lines changed Expand file tree Collapse file tree 7 files changed +205
-163
lines changed Original file line number Diff line number Diff line change 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 {
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
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 } ;
Original file line number Diff line number Diff line change 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+ {
15+ type = if primaryPartitionType == "legacyBoot" then "table" else "gpt" ;
16+ partitions =
17+ if primaryPartitionType == "legacyBoot" then
18+ import ./zfs-legacy-boot.nix
19+ else if primaryPartitionType == "ext4" then
20+ import ./ext4.nix
21+ else
22+ import ./zfs.nix ;
23+ }
24+ // lib . optionalAttrs primaryPartitionType == "legacyBoot" {
25+ format = "gpt" ;
26+ } ;
27+ }
Original file line number Diff line number Diff line change 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 = "500M" ;
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+ }
Original file line number Diff line number Diff line change 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+ ]
Original file line number Diff line number Diff line change 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+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments