Skip to content

bug: standalone disko does not support flakes #1074

Open
@midischwarz12

Description

@midischwarz12

Description

The standalone disko cli tool cannot be used with the diskoConfigurations output schema.

Steps to Reproduce

  1. Create a disko configuration in a flake of the output schema diskoConfigurations.
  2. With any mode, --dry-run or not, run disko --flake '<flake-uri>#<flake-attribute>'

Expected Behavior

The disko standalone cli tool would format, mount, destroy, etc according to the specified disko configuration in the flake.

Actual Behavior

The following error is thrown when the configuration is an attrset:

disko version 1.12.0-dirty
evaluation warning: the format output is deprecated and will be removed, please open an issue if you're using it!
error: attempt to call something which is not a function but a string: "set -efux\n\ndisko_devices_dir=$(mktemp -d)\ntrap 'rm -rf \"$disko_devices_dir\"' EXIT\nmkdir -p \"$disko_devices_dir\"\n\n( # disk main /dev/sbc   #\n  destroy=1\n  device=/dev/sbc\n  imageName=main\n  imageSize=2G\n  name=main\n  type=disk\n  \n  ( # gpt  /dev/sbc   #\n    device=/dev/sbc\n    efiGptPartitionFirst=1\n    type=gpt\n    \n    if ! blkid \"/dev/sbc\" >&2; then\n      sgdisk --clear \"/dev/sbc\"\n    fi\n    # try to create the partition, if it fails, try to change the type and name\n    if ! sgdisk --align-end  \\\n    --new=1:0:+1M \\\n     --partition-guid=\"1:R\" \\\n    --change-name=\"1:disk-main-MBR\" \\\n    --typecode=1:EF02 \\\n    \"/dev/sbc\" \\\n    \n    then\n      sgdisk --partition-guid=\"1:R\" \\\n    --change-name=\"1:disk-main-MBR\" \\\n    --typecode=1:EF02 \\\n    \"/dev/sbc\" \\\n    \n    fi\n    # ensure /dev/disk/by-path/..-partN exists before continuing\n    partprobe \"/dev/sbc\" || : # sometimes partprobe fails, but the partitions are still up2date\n    udevadm trigger --subsystem-match=block\n    udevadm settle --timeout 120\n    \n    \n" «48 bytes elided»
       at /nix/store/qv4aa8vmy4k7fh1vvxxn39nb6f7m4xs7-disko/share/disko/cli.nix:103:15:
          102|
          103|   diskoEval = disko.${diskoAttr} diskFormat pkgs;
             |               ^
          104|

The following error is thrown when the configuration is a function that returns an attrset:

disko version 1.12.0-dirty
evaluation warning: the format output is deprecated and will be removed, please open an issue if you're using it!
error: attempt to call something which is not a function but a string: "set -efux\n\ndisko_devices_dir=$(mktemp -d)\ntrap 'rm -rf \"$disko_devices_dir\"' EXIT\nmkdir -p \"$disko_devices_dir\"\n\n( # disk main /dev/sbc   #\n  destroy=1\n  device=/dev/sbc\n  imageName=main\n  imageSize=2G\n  name=main\n  type=disk\n  \n  ( # gpt  /dev/sbc   #\n    device=/dev/sbc\n    efiGptPartitionFirst=1\n    type=gpt\n    \n    if ! blkid \"/dev/sbc\" >&2; then\n      sgdisk --clear \"/dev/sbc\"\n    fi\n    # try to create the partition, if it fails, try to change the type and name\n    if ! sgdisk --align-end  \\\n    --new=1:0:+1M \\\n     --partition-guid=\"1:R\" \\\n    --change-name=\"1:disk-main-MBR\" \\\n    --typecode=1:EF02 \\\n    \"/dev/sbc\" \\\n    \n    then\n      sgdisk --partition-guid=\"1:R\" \\\n    --change-name=\"1:disk-main-MBR\" \\\n    --typecode=1:EF02 \\\n    \"/dev/sbc\" \\\n    \n    fi\n    # ensure /dev/disk/by-path/..-partN exists before continuing\n    partprobe \"/dev/sbc\" || : # sometimes partprobe fails, but the partitions are still up2date\n    udevadm trigger --subsystem-match=block\n    udevadm settle --timeout 120\n    \n    \n" «48 bytes elided»
       at /nix/store/qv4aa8vmy4k7fh1vvxxn39nb6f7m4xs7-disko/share/disko/cli.nix:103:15:
          102|
          103|   diskoEval = disko.${diskoAttr} diskFormat pkgs;
             |               ^
          104|

The following error is thrown when the configuration is a function that returns a function:

disko version 1.12.0-dirty
evaluation warning: the format output is deprecated and will be removed, please open an issue if you're using it!
error:
       … while calling the 'warn' builtin
         at /nix/store/qv4aa8vmy4k7fh1vvxxn39nb6f7m4xs7-disko/share/disko/default.nix:70:17:
           69|
           70|   format = cfg: warnDeprecated "format" (eval cfg).config.disko.devices._create;
             |                 ^
           71|   formatScript =

       … while evaluating the attribute 'value'
         at /nix/store/p7qab3pywvzcif107lh81wpkadd6l0qr-a4wf74piifb6cpmkyisrzjcac62dvf9q-source/lib/modules.nix:1084:7:
         1083|     // {
         1084|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |       ^
         1085|       inherit (res.defsFinal') highestPrio;

       … while evaluating the option `disko.devices':

       … while evaluating definitions from `<unknown-file>':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: expected a set but found a function: «lambda nixos @ /nix/store/rhmk70ll5rsv7clwjsl9s2l8d6624ww9-source/flake.nix:118:18»

It does not seem like there is any possible way to get it to evaluate.

Possible Fix

After reading and hacking around both disko and cli.nix, it seems like disko is doing all the things it needs to and properly evaluating cli.nix with the correct arg strings. And it seems that cli.nix properly handles --no-deps. However, there is only branches for standalone disko file and no disko file both with their legacy aliases. I believe there should be another branch unless I'm mistaken and the "no disko file" branch is supposed to also be the flake branch. In that case, the behavior of such is incorrect and maybe the flake should correspond with the formatScript, mountScript, etc like in disko-install.

Environment

  • disko version: 1.12.0 stable (and tried on the latest 1.12.0 commit)
  • system: "x86_64-linux"
  • host os: Linux 6.12.33, NixOS, 25.05 (Warbler), 25.05.20250618.9ba04bd
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.28.3
  • nixpkgs: /nix/store/nj4pscwrcbmm7ib6zwpgsv47rnd9jrq2-source

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions