File tree Expand file tree Collapse file tree 7 files changed +225
-164
lines changed Expand file tree Collapse file tree 7 files changed +225
-164
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 {
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 ;
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+ type = if primaryPartitionType == "legacyBoot" then "table" else "gpt" ;
15+ partitions =
16+ if primaryPartitionType == "legacyBoot" then
17+ import ./zfs-legacy-boot.nix {
18+ inherit
19+ isSecondary
20+ espSize
21+ swapSize
22+ poolName
23+ ;
24+ }
25+ else if primaryPartitionType == "ext4" then
26+ import ./ext4.nix { inherit espSize ; }
27+ else
28+ import ./zfs.nix {
29+ inherit
30+ disk
31+ isSecondary
32+ espSize
33+ swapSize
34+ poolName
35+ ;
36+ } ;
37+ }
38+ // lib . optionalAttrs ( primaryPartitionType == "legacyBoot" ) {
39+ format = "gpt" ;
40+ } ;
41+ }
Original file line number Diff line number Diff line change 1+ { espSize } :
2+ {
3+ ESP = {
4+ type = "EF00" ;
5+ size = espSize ;
6+ content = {
7+ type = "filesystem" ;
8+ format = "vfat" ;
9+ mountpoint = "/boot" ;
10+ mountOptions = [ "umask=0077" ] ;
11+ } ;
12+ } ;
13+ nixos = {
14+ size = "100%" ;
15+ content = {
16+ type = "filesystem" ;
17+ format = "ext4" ;
18+ mountpoint = "/" ;
19+ } ;
20+ } ;
21+ }
Original file line number Diff line number Diff line change 1+ {
2+ isSecondary ,
3+ espSize ,
4+ swapSize ,
5+ poolName ,
6+ } :
7+ [
8+ {
9+ name = "boot" ;
10+ start = "1MiB" ;
11+ end = "2MiB" ;
12+ part-type = "primary" ;
13+ flags = [ "bios_grub" ] ;
14+ }
15+ {
16+ name = "ESP" ;
17+ start = "2MiB" ;
18+ end = espSize ;
19+ bootable = true ;
20+ content = {
21+ type = "filesystem" ;
22+ format = "vfat" ;
23+ mountpoint = if isSecondary then null else "/boot" ;
24+ } ;
25+ }
26+ {
27+ name = "zfs" ;
28+ start = espSize ;
29+ end = "-${ swapSize } " ;
30+ part-type = "primary" ;
31+ content = {
32+ type = "zfs" ;
33+ pool = "${ poolName } " ;
34+ } ;
35+ }
36+ {
37+ name = "swap" ;
38+ start = "-${ swapSize } " ;
39+ end = "100%" ;
40+ part-type = "primary" ;
41+ content = {
42+ type = "swap" ;
43+ randomEncryption = true ;
44+ } ;
45+ }
46+ ]
Original file line number Diff line number Diff line change 1+ {
2+ disk ,
3+ isSecondary ,
4+ espSize ,
5+ swapSize ,
6+ poolName ,
7+ } :
8+ {
9+ "ESP" = {
10+ device = "${ disk } -part1" ;
11+ size = espSize ;
12+ type = "EF00" ;
13+ content = {
14+ type = "filesystem" ;
15+ format = "vfat" ;
16+ mountpoint = if isSecondary then null else "/boot" ;
17+ mountOptions = [ "umask=0077" ] ;
18+ } ;
19+ } ;
20+
21+ "zfs" = {
22+ device = "${ disk } -part2" ;
23+ end = "-${ swapSize } " ;
24+ type = "BF00" ;
25+ content = {
26+ type = "zfs" ;
27+ pool = "${ poolName } " ;
28+ } ;
29+ } ;
30+
31+ "swap" = {
32+ device = "${ disk } -part3" ;
33+ size = swapSize ;
34+ content = {
35+ type = "swap" ;
36+ randomEncryption = true ;
37+ } ;
38+ } ;
39+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments