diff --git a/iso/common.nix b/iso/common.nix index ce8ec62..0937431 100644 --- a/iso/common.nix +++ b/iso/common.nix @@ -55,7 +55,6 @@ in gsettings-desktop-schemas adwaita-icon-theme util-linux - disko parted dosfstools e2fsprogs diff --git a/iso/disko.nix b/iso/disko.nix deleted file mode 100644 index 568d1ad..0000000 --- a/iso/disko.nix +++ /dev/null @@ -1,59 +0,0 @@ -{ device ? "/dev/sda", dataDevice ? "", ... }: - -{ - disko.devices = { - disk = { - main = { - type = "disk"; - device = builtins.toString device; - content = { - type = "gpt"; - partitions = { - ESP = { - priority = 1; - name = "ESP"; - size = "512M"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot/efi"; - mountOptions = [ "umask=0077" "defaults" ]; - }; - }; - root = { - name = "root"; - size = "100%"; - content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/"; - extraArgs = [ "-L" "sovran_systemsos" ]; - }; - }; - }; - }; - }; - } // (if dataDevice != "" then { - data = { - type = "disk"; - device = builtins.toString dataDevice; - content = { - type = "gpt"; - partitions = { - primary = { - name = "primary"; - size = "100%"; - content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/run/media/Second_Drive"; - extraArgs = [ "-L" "BTCEcoandBackup" ]; - }; - }; - }; - }; - }; - } else {}); - }; -} \ No newline at end of file diff --git a/iso/installer.py b/iso/installer.py index 0c9488c..991d438 100644 --- a/iso/installer.py +++ b/iso/installer.py @@ -710,7 +710,7 @@ class InstallerWindow(Adw.ApplicationWindow): boot_path = f"/dev/{self.boot_disk}" data_path = f"/dev/{self.data_disk}" if self.data_disk else None - # ── Wipe disk(s) to clear stale GPT/MBR data before disko ── + # ── Wipe disk(s) ── GLib.idle_add(append_text, buf, "=== Wiping disk(s) ===\n") run_stream(["sudo", "sgdisk", "--zap-all", boot_path], buf) @@ -720,26 +720,54 @@ class InstallerWindow(Adw.ApplicationWindow): run_stream(["sudo", "sgdisk", "--zap-all", data_path], buf) run_stream(["sudo", "wipefs", "--all", "--force", data_path], buf) - # Inform the kernel of the wiped partition tables run_stream(["sudo", "partprobe", boot_path], buf) if data_path: run_stream(["sudo", "partprobe", data_path], buf) - # Short settle so the kernel finishes re-reading time.sleep(2) - # ── Now run disko to partition, format, and mount ── - # Disks are already wiped clean by sgdisk/wipefs above, - # so we only need disko to create partitions, format, and mount. - GLib.idle_add(append_text, buf, "\n=== Partitioning and formatting drives ===\n") - cmd = [ - "sudo", "disko", "--mode", "format,mount", - f"{FLAKE}/iso/disko.nix", - "--arg", "device", boot_path - ] + # ── Partition boot disk: 512M ESP + rest as root ── + GLib.idle_add(append_text, buf, "\n=== Partitioning boot disk ===\n") + run_stream(["sudo", "sgdisk", + "-n", "1:1M:+512M", "-t", "1:EF00", "-c", "1:ESP", + "-n", "2:0:0", "-t", "2:8300", "-c", "2:root", + boot_path], buf) + + run_stream(["sudo", "partprobe", boot_path], buf) + time.sleep(2) + + # ── Partition data disk (if selected) ── if data_path: - cmd += ["--arg", "dataDevice", data_path] - run_stream(cmd, buf) + GLib.idle_add(append_text, buf, "\n=== Partitioning data disk ===\n") + run_stream(["sudo", "sgdisk", + "-n", "1:1M:0", "-t", "1:8300", "-c", "1:primary", + data_path], buf) + + run_stream(["sudo", "partprobe", data_path], buf) + time.sleep(2) + + # ── Format partitions ── + GLib.idle_add(append_text, buf, "\n=== Formatting partitions ===\n") + boot_p1 = f"{boot_path}p1" if "nvme" in boot_path else f"{boot_path}1" + boot_p2 = f"{boot_path}p2" if "nvme" in boot_path else f"{boot_path}2" + + run_stream(["sudo", "mkfs.vfat", "-F", "32", boot_p1], buf) + run_stream(["sudo", "mkfs.ext4", "-F", "-L", "sovran_systemsos", boot_p2], buf) + + if data_path: + data_p1 = f"{data_path}p1" if "nvme" in data_path else f"{data_path}1" + run_stream(["sudo", "mkfs.ext4", "-F", "-L", "BTCEcoandBackup", data_p1], buf) + + # ── Mount filesystems ── + GLib.idle_add(append_text, buf, "\n=== Mounting filesystems ===\n") + run_stream(["sudo", "mount", boot_p2, "/mnt"], buf) + run_stream(["sudo", "mkdir", "-p", "/mnt/boot/efi"], buf) + run_stream(["sudo", "mount", "-o", "umask=0077,defaults", boot_p1, "/mnt/boot/efi"], buf) + + if data_path: + data_p1 = f"{data_path}p1" if "nvme" in data_path else f"{data_path}1" + run_stream(["sudo", "mkdir", "-p", "/mnt/run/media/Second_Drive"], buf) + run_stream(["sudo", "mount", data_p1, "/mnt/run/media/Second_Drive"], buf) GLib.idle_add(append_text, buf, "\n=== Generating hardware config ===\n") run_stream(["sudo", "nixos-generate-config", "--root", "/mnt"], buf)