disko icon indicating copy to clipboard operation
disko copied to clipboard

What's wrong with the config below?

Open nikolay opened this issue 2 years ago • 7 comments

I get this error:

image

With this config:

{
  disks,
  lib,
  ...
}: {
  disko.devices = {
    disk = lib.genAttrs disks (device: {
      type = "disk";
      name = lib.removePrefix "_" (builtins.replaceStrings ["/"] ["_"] device);
      device = device;
      content = {
        type = "gpt";
        partitions =
          (
            lib.mkIf (device == (builtins.elemAt disks 0)) {
              esp = {
                type = "EF00";
                size = "512M";
                content = {
                  type = "filesystem";
                  format = "vfat";
                  mountpoint = "/boot";
                };
              };
            }
          )
          // {
            zfs = {
              size = "100%";
              content = {
                type = "zfs";
                pool = "zroot";
              };
            };
          };
      };
    });
    zpool = {
      zroot = {
        type = "zpool";
        mode = "raidz";
        rootFsOptions = {
          compression = "zstd";
          "com.sun:auto-snapshot" = "false";
        };
        datasets = {
          "data" = {
            type = "zfs_fs";
            options.mountpoint = "none";
          };
          "ROOT" = {
            type = "zfs_fs";
            options.mountpoint = "none";
          };
          "ROOT/empty" = {
            type = "zfs_fs";
            mountpoint = "/";
            options.mountpoint = "legacy";
            postCreateHook = ''
              zfs snapshot zroot/ROOT/empty@start
            '';
          };
          "ROOT/nix" = {
            type = "zfs_fs";
            mountpoint = "/nix";
            options.mountpoint = "legacy";
          };
        };
      };
    };
  };
}

nikolay avatar Sep 10 '23 05:09 nikolay

The issue was my deployment script. Sorry.

nikolay avatar Sep 10 '23 06:09 nikolay

Never mind, it wasn't the deployment script.

nikolay avatar Sep 10 '23 06:09 nikolay

        lib.mkIf (device == (builtins.elemAt disks 0)) {

I believe you can just use if (device == (builtins.elemAt disks 0)) then ... else ....

phaer avatar Sep 10 '23 09:09 phaer

@phaer Yeah, sorry. My last version, which works, is this one:

{
  disks ? ["/dev/sda" "/dev/sdb" "/dev/sdc"],
  lib,
  ...
}: let
  zfs = {
    type = "zfs";
    pool = "zroot";
  };
in {
  disko.devices = {
    disk = lib.genAttrs disks (device: {
      type = "disk";
      name = lib.removePrefix "_" (builtins.replaceStrings ["/"] ["_"] device);
      device = device;
      content =
        if (device == (builtins.elemAt disks 0))
        then {
          type = "gpt";
          partitions = {
            esp = {
              type = "EF00";
              size = "512M";
              content = {
                type = "filesystem";
                format = "vfat";
                mountpoint = "/boot";
              };
            };
            zfs = {
              size = "100%";
              content = zfs;
            };
          };
        }
        else zfs;
    });
    zpool = {
      zroot = {
        type = "zpool";
        mode = "raidz";
        rootFsOptions = {
          compression = "zstd";
          "com.sun:auto-snapshot" = "false";
        };
        mountpoint = "/";
        postCreateHook = "zfs snapshot zroot@blank";
        datasets = {
          "root" = {
            type = "zfs_fs";
            options.mountpoint = "none";
          };
        };
      };
    };
  };
}

So, I guess, some of the examples don't really work, i.e. those having partitions with just zfs.

Yet, not the issue is that bootctl fails:

image

nikolay avatar Sep 10 '23 15:09 nikolay

So, I guess, some of the examples don't really work, i.e. those having partitions with just zfs.

Did you test the examples to verify? If so, can you post a log? :)

Yet, not the issue is that bootctl fails:

It says that /boot does not exist - did you check the log above whether it actually gets created and mounted? You should see creation and mount commands with --debug.

phaer avatar Sep 10 '23 18:09 phaer

@phaer It wasn't getting created, and I'm not sure how I've fixed it, but it works now. All my code is here: https://github.com/nikolay/zfs-on-nix-test

I'm basically trying to run NixOS on Scaleway Dedibox, but I'm a total noob when it comes to Nix, NixOS, and ZFS.

Now, the error is different:

image

nikolay avatar Sep 10 '23 20:09 nikolay

@phaer Unfortunately, /boot randomly does not mount during the installation. 😒 The second time I ran the script, it failed again. I am a little concerned about nixos-install not failing when a critical part fails.

nikolay avatar Sep 10 '23 21:09 nikolay