Disko: Dualbooting Windows and NixOS

I have only started using NixOS and disko (with nixos-anywhere) recently, so this may be a user skill issue on my side.
My problem: In my config I only declare the NixOS partitions, but I also have Windows installed on the same drive. During installation the Windows partitions just get discarded. instead I’d like disko to just leave them alone and only create the NixOS partitions “on top”. My current setup is:


{ lib, ... }:
{
  disko.devices = {
    disk = {
      main = {
        device = lib.mkDefault "/dev/nvme0n1";
        type = "disk";
        content = {
          type = "gpt";
          partitions = {
            ESP = {
              type = "EF00";
              size = "500M";
              content = {
                type = "filesystem";
                format = "vfat";
                mountpoint = "/boot";
                mountOptions = [ "umask=0077" ];
              };
            };
            root = {
              size = "400G";
              content = {
                type = "filesystem";
                format = "ext4";
                mountpoint = "/";
              };
            };
          };
        };
      };
    };
  };
}

Everything is set up correctly, I have performed multiple good installs (apart from this issue) with this config, so it must be a misconfiguration or an issue with disko.
Any help is appreciated!

Hello
As said in this comment:

It won’t work.
Only option would be that you put windows on a separate drive.

1 Like

systemd-repart is better suited for making non-destructive changes to an existing disk layout, but no one’s written nixos tooling that’s as convenient and automated for setting up a new system via systemd-repart. We have tools for creating bootable nixos disk images with systemd-repart, and we have modules for running systemd-repart during boot. But there’s not one tool that takes a nixos systemd-repart config and applies that to a target disk for the purpose of installing nixos. But it would be totally possible and it’d be nice for that to exist.

5 Likes