File tree Expand file tree Collapse file tree 7 files changed +244
-165
lines changed Expand file tree Collapse file tree 7 files changed +244
-165
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+ partitioningPreset = mkOption {
22+ type = types . enum [
23+ "zfs"
24+ "zfs-legacy-boot"
25+ "ext4"
26+ ] ;
27+ default = "zfs" ;
28+ example = "zfs-legacy-boot" ;
29+ description = "Declare the type of the primary partition" ;
2630 } ;
2731
2832 swapSize = mkOption {
29- type = types . str ;
33+ type = types . nullOr types . str ;
3034 default = "32G" ;
3135 example = "32768M" ;
3236 description = "The size of the hard disk space used when RAM is full" ;
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+ partitioningPreset = cfg . partitioningPreset ;
163167 poolName = cfg . zpool . name ;
164168 }
165169 else
180184 isSecondary = false ;
181185 espSize = cfg . espSize ;
182186 swapSize = cfg . swapSize ;
183- legacyBoot = cfg . legacyBoot ;
187+ partitioningPreset = cfg . partitioningPreset ;
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+ partitioningPreset = cfg . partitioningPreset ;
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+ partitioningPreset ,
8+ poolName ,
9+ } :
10+ {
11+ type = "disk" ;
12+ device = disk ;
13+ content = {
14+ type = if partitioningPreset == "zfs-legacy-boot" then "table" else "gpt" ;
15+ partitions =
16+ if partitioningPreset == "zfs-legacy-boot" then
17+ import ./zfs-legacy-boot.nix {
18+ inherit
19+ lib
20+ isSecondary
21+ espSize
22+ swapSize
23+ poolName
24+ ;
25+ }
26+ else if partitioningPreset == "ext4" then
27+ import ./ext4.nix { inherit lib espSize ; }
28+ else
29+ import ./zfs.nix {
30+ inherit
31+ lib
32+ disk
33+ isSecondary
34+ espSize
35+ swapSize
36+ poolName
37+ ;
38+ } ;
39+ }
40+ // lib . optionalAttrs ( partitioningPreset == "zfs-legacy-boot" ) {
41+ format = "gpt" ;
42+ } ;
43+ }
Original file line number Diff line number Diff line change 1+ { lib , 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+ start = espSize ;
15+ end = if swapSize != null then "-${ swapSize } " else "100%" ;
16+ content = {
17+ type = "filesystem" ;
18+ format = "ext4" ;
19+ mountpoint = "/" ;
20+ } ;
21+ }
22+ // lib . optionalAttrs ( swapSize != null ) {
23+ "swap" = {
24+ size = swapSize ;
25+ content = {
26+ type = "swap" ;
27+ randomEncryption = true ;
28+ } ;
29+ } ;
30+ } ;
31+ }
Original file line number Diff line number Diff line change 1+ {
2+ lib ,
3+ isSecondary ,
4+ espSize ,
5+ swapSize ,
6+ poolName ,
7+ } :
8+ [
9+ {
10+ name = "boot" ;
11+ start = "1MiB" ;
12+ end = "2MiB" ;
13+ part-type = "primary" ;
14+ flags = [ "bios_grub" ] ;
15+ }
16+ {
17+ name = "ESP" ;
18+ start = "2MiB" ;
19+ end = espSize ;
20+ bootable = true ;
21+ content = {
22+ type = "filesystem" ;
23+ format = "vfat" ;
24+ mountpoint = if isSecondary then null else "/boot" ;
25+ } ;
26+ }
27+ {
28+ name = "zfs" ;
29+ start = espSize ;
30+ end = if swapSize != null then "-${ swapSize } " else "100%" ;
31+ part-type = "primary" ;
32+ content = {
33+ type = "zfs" ;
34+ pool = "${ poolName } " ;
35+ } ;
36+ }
37+
38+ ]
39+ ++ lib . optional ( swapSize != null ) [
40+ {
41+ name = "swap" ;
42+ start = "-${ swapSize } " ;
43+ end = "100%" ;
44+ part-type = "primary" ;
45+ content = {
46+ type = "swap" ;
47+ randomEncryption = true ;
48+ } ;
49+ }
50+ ]
Original file line number Diff line number Diff line change 1+ {
2+ lib ,
3+ disk ,
4+ isSecondary ,
5+ espSize ,
6+ swapSize ,
7+ poolName ,
8+ } :
9+ {
10+ "ESP" = {
11+ device = "${ disk } -part1" ;
12+ size = espSize ;
13+ type = "EF00" ;
14+ content = {
15+ type = "filesystem" ;
16+ format = "vfat" ;
17+ mountpoint = if isSecondary then null else "/boot" ;
18+ mountOptions = [ "umask=0077" ] ;
19+ } ;
20+ } ;
21+
22+ "zfs" = {
23+ device = "${ disk } -part2" ;
24+ end = if swapSize != null then "-${ swapSize } " else "100%" ;
25+ type = "BF00" ;
26+ content = {
27+ type = "zfs" ;
28+ pool = "${ poolName } " ;
29+ } ;
30+ }
31+ // lib . optionalAttrs ( swapSize != null ) {
32+ "swap" = {
33+ device = "${ disk } -part3" ;
34+ size = swapSize ;
35+ content = {
36+ type = "swap" ;
37+ randomEncryption = true ;
38+ } ;
39+ } ;
40+ } ;
41+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments