Skip to content

Migrate disko config from clanModules.disk-id

If you previously bootstrapped a machine's disk using clanModules.disk-id, you should now migrate to a standalone, self-contained disko configuration. This ensures long-term stability and avoids reliance on dynamic values from Clan.

If your disko.nix currently looks something like this:

disko.nix
{
  lib,
  clan-core,
  config,
  ...
}:

let
  suffix = config.clan.core.vars.generators.disk-id.files.diskId.value;
in
{
  imports = [
    clan-core.clanModules.disk-id
  ];

  # DO NOT EDIT THIS FILE AFTER INSTALLATION of a machine
  # Otherwise your system might not boot because of missing partitions / filesystems
  boot.loader.grub.efiSupport = lib.mkDefault true;
  boot.loader.grub.efiInstallAsRemovable = lib.mkDefault true;
  disko.devices = {
    disk = {
      "main" = {
        # suffix is to prevent disk name collisions
        name = "main-" + suffix;
        type = "disk";
        # Set the following in flake.nix for each maschine:
        # device = <uuid>;
        content = {
          # edlied
        };
      };
    };
  };
}

Step 1: Retrieve your disk-id

Run the following command to retrieve the generated disk ID for your machine:

clan vars list <machineName>

Which should print the generated disk-id/diskId value in clear text You should see output like:

disk-id/diskId: fcef30a749f8451d8f60c46e1ead726f
# ...
# elided

Copy this value โ€” you'll need it in the next step.

โœ๏ธ Step 2: Replace Dynamic Configuration with Static Values

โœ… Goal: Make your disko.nix file standalone.

We are going to make three changes:

  • Remove let in, imports, {lib,clan-core,config, ...}: to isolate the file.
  • Replace suffix with the actual disk-id
  • Move disko.devices.disk.main.device from flake.nix or configuration.nix into this file.
disko.nix
{
  boot.loader.grub.efiSupport = lib.mkDefault true;
  boot.loader.grub.efiInstallAsRemovable = lib.mkDefault true;
  disko.devices = {
    disk = {
      "main" = {
        #       โ†“ Copy the disk-id into place
        name = "main-fcef30a749f8451d8f60c46e1ead726f";
        type = "disk";

        # Some earlier guides had this line in a flake.nix
        # disko.devices.disk.main.device = "/dev/disk/by-id/__CHANGE_ME__";
        #        โ†“ Copy the '/dev/disk/by-id' into here instead
        device = "/dev/disk/by-id/nvme-eui.e8238fa6bf530001001b448b4aec2929";

        # edlied;
      };
    };
  };
}

These steps are only needed for existing configurations that depend on the diskId module.

For newer machines clan offers simple disk templates via its templates cli