summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2023-07-08 11:16:40 +0200
committerSoispha <soispha@vhack.eu>2023-07-08 11:16:40 +0200
commit40458f49ebada72ccd8c62ac16d1a9b5c4345b80 (patch)
tree9637b90f4ccea3fe4327db6220f836f13c5a9845
parentMerge branch 'disko' (diff)
downloadnixos-server-40458f49ebada72ccd8c62ac16d1a9b5c4345b80.tar.gz
nixos-server-40458f49ebada72ccd8c62ac16d1a9b5c4345b80.zip
Fix(system/disks): Change partitioning scheme to support gpt/bios boot
-rw-r--r--hosts/server1/hardware.nix1
-rw-r--r--system/disks/default.nix62
2 files changed, 42 insertions, 21 deletions
diff --git a/hosts/server1/hardware.nix b/hosts/server1/hardware.nix
index 9fabafe..6086362 100644
--- a/hosts/server1/hardware.nix
+++ b/hosts/server1/hardware.nix
@@ -3,6 +3,7 @@
     (modulesPath + "/profiles/qemu-guest.nix")
     (modulesPath + "/profiles/headless.nix")
   ];
+  # FIXME: The name of the grub device depends on the disko settings
   boot.loader.grub.device = "/dev/vda";
   boot.initrd.availableKernelModules = ["ata_piix" "uhci_hcd" "virtio_pci" "sr_mod" "virtio_blk"];
   boot.initrd.kernelModules = [];
diff --git a/system/disks/default.nix b/system/disks/default.nix
index 24898fe..5453426 100644
--- a/system/disks/default.nix
+++ b/system/disks/default.nix
@@ -7,7 +7,6 @@ with lib; let
   cfg = config.system.disks;
   defaultMountOptions = ["compress-force=zstd:15"];
 in {
-
   options.system.disks = {
     disk = mkOption {
       type = lib.types.path;
@@ -21,26 +20,47 @@ in {
       disk.main = {
         device = cfg.disk;
         content = {
-          type = "btrfs";
-          extraArgs = ["-f" "--label nixos"]; # f: Override existing partitions
-          subvolumes = {
-            "nix" = {
-              mountpoint = "/nix";
-              mountOptions = defaultMountOptions;
-            };
-            "persistent-storage" = {
-              mountpoint = "/srv";
-              mountOptions = defaultMountOptions;
-            };
-            "persistent-storage@snapshots" = {
-              mountpoint = "/srv/.snapshots";
-              mountOptions = defaultMountOptions;
-            };
-            "boot" = {
-              mountpoint = "/boot";
-              mountOptions = defaultMountOptions;
-            };
-          };
+          type = "table";
+          format = "gpt";
+          partitions = [
+            {
+              name = "boot";
+              start = "0";
+              end = "1M";
+              part-type = "primary";
+              flags = ["bios_grub"];
+            }
+            {
+              name = "root";
+              # leave space for the grub aka BIOS boot
+              start = "1M";
+              end = "100%";
+              part-type = "primary";
+              bootable = true;
+              content = {
+                type = "btrfs";
+                extraArgs = ["-f" "--label nixos"]; # f: Override existing partitions
+                subvolumes = {
+                  "nix" = {
+                    mountpoint = "/nix";
+                    mountOptions = defaultMountOptions;
+                  };
+                  "persistent-storage" = {
+                    mountpoint = "/srv";
+                    mountOptions = defaultMountOptions;
+                  };
+                  "persistent-storage@snapshots" = {
+                    mountpoint = "/srv/.snapshots";
+                    mountOptions = defaultMountOptions;
+                  };
+                  "boot" = {
+                    mountpoint = "/boot";
+                    mountOptions = defaultMountOptions;
+                  };
+                };
+              };
+            }
+          ];
         };
       };
       nodev = {