disko icon indicating copy to clipboard operation
disko copied to clipboard

NixOS modules with disko config don't merge

Open jmbaur opened this issue 1 year ago • 3 comments

I would expect setting disko config in two different NixOS modules would properly merge together. A minimal reproducer is the config below, where I would expect evaluating it to fail with conflicting definitions for mountpoint, but rather the mountpoint ends up getting set to /boot.

let
  nixpkgs = builtins.getFlake "github:nixos/nixpkgs/nixos-unstable";
  disko = builtins.getFlake "github:nix-community/disko/master";
in
(nixpkgs.lib.nixosSystem {
  modules = [
    disko.nixosModules.default
    { nixpkgs.hostPlatform = "x86_64-linux"; }
    {
      disko.devices.disk.disk0 = {
        device = "/dev/foobar";
        type = "disk";
        content = {
          type = "gpt";
          partitions.foo = {
            type = "EF00";
            content = {
              type = "filesystem";
              format = "vfat";
              mountpoint = "/boot";
            };
          };
        };
      };
    }
    {
      disko.devices.disk.disk0 = {
        type = "disk";
        content = {
          type = "gpt";
          partitions.foo = {
            type = "EF00";
            content = {
              type = "filesystem";
              mountpoint = null;
            };
          };
        };
      };
    }
  ];
}).config.disko.devices.disk.disk0.content.partitions.foo.content.mountpoint

jmbaur avatar Jun 17 '24 17:06 jmbaur

but you have conflicting definitions? not sure whats the error here? what should happen otherwise?

Lassulus avatar Jun 17 '24 17:06 Lassulus

That's the thing, I would expect that evaluating the above expression would error out due to the fact that there are conflicting definitions, but it does not.

Result from evaluation (where test.nix contains the contents as posted above):

~ > nix eval -f test.nix
"/boot"

jmbaur avatar Jun 17 '24 18:06 jmbaur

Seems related: https://github.com/NixOS/nixpkgs/pull/254790#discussion_r1358073458

jmbaur avatar Jun 17 '24 18:06 jmbaur

Ah this should be fixed now

Lassulus avatar Aug 04 '25 06:08 Lassulus

Fixed by #1094

Enzime avatar Aug 04 '25 06:08 Enzime