disko icon indicating copy to clipboard operation
disko copied to clipboard

error: attribute 'disko' missing

Open StijnRuts opened this issue 1 year ago • 3 comments

I am trying to use disko from the installation environment, but I get this error:

[root@nixos:~]# nix --experimental-features "nix-command flakes" flake init --template github:nix-community/disko-templates#single-disk-ext4
wrote: /root/disko-config.nix

[root@nixos:~]# vim disko-config.nix
( added  device = "/dev/sda"; )

[root@nixos:~]# nix --experimental-features "nix-command flakes" run github:nix-community/disko -- --mode disko ./disko-config.nix
error:
       … while evaluating the attribute 'value'

         at /nix/store/p2zlnhfbwx66hmp4l8m3qyyj3yrfr9zh-9qq0zf30wi74pz66rr05zmxq0nv17q1p-source/lib/modules.nix:821:9:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          822|         inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin

         at /nix/store/p2zlnhfbwx66hmp4l8m3qyyj3yrfr9zh-9qq0zf30wi74pz66rr05zmxq0nv17q1p-source/lib/modules.nix:821:17:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |                 ^
          822|         inherit (res.defsFinal') highestPrio;

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

       error: attribute 'disko' missing

       at /nix/store/i88xqmnhi9rwanwymlma7p6drql2qc5j-disko/share/disko/default.nix:10:49:

            9|       # _file = toString input;
           10|       imports = lib.singleton { disko.devices = cfg.disko.devices; };
             |                                                 ^
           11|       options = {

StijnRuts avatar Sep 10 '24 17:09 StijnRuts

When I change config.disko.devices to disko.devices it does work. (Tough I do still get an error about "wrong fs type" on mount)

StijnRuts avatar Sep 10 '24 18:09 StijnRuts

Tough I do still get an error about "wrong fs type" on mount

When I look at my disk in gparted, the root partition is listed as type swap instead of ext4.

StijnRuts avatar Sep 10 '24 18:09 StijnRuts

Could you post the entirety of your /root/disko-config.nix?

iFreilicht avatar Sep 20 '24 22:09 iFreilicht

I'm also having this issue, I haven't been able to fix it with any workarounds though. AFAIK I followed the template pretty closely, only changed things specific to my setup. Can send my disko-config.nix if needed.

vennsofar avatar Oct 08 '24 16:10 vennsofar

@vennsofar I ended up with this configuration: https://github.com/StijnRuts/NixOS-config/blob/c5369206161d2b3352a3dbaa8417f6f030ba18e3/disko/T420.nix

Can send my disko-config.nix if needed.

I can take a look. No promise that I'll find the issue tough.

StijnRuts avatar Oct 08 '24 18:10 StijnRuts

https://github.com/user-attachments/files/17297572/disko-config.txt Here's mine. What I was intending was to have a 1.5Gb Efi, 30Gb swap, and have the rest of the drive be ZFS split up into a similar setup as found on the NixOS wiki page.

Thanks in advance if you do end up taking a look at it.

vennsofar avatar Oct 08 '24 18:10 vennsofar

@vennsofar Your config looks fine, as far as I can tell. The only thing I am unsure of is size = "1.5G";. I don't know if decimals are accepted. Maybe try size = "1500M";. I had issues with zfs, which is why I switched to btrfs.

StijnRuts avatar Oct 08 '24 18:10 StijnRuts

@vennsofar Your top-level attribute is disk, but it should be disko.devices.disk

iFreilicht avatar Oct 09 '24 05:10 iFreilicht

Looks like including both fixes got past the the Nix errors, but the program still isn't finishing correctly, only the first partition is being created, but not being formatted. None of the other partitions (Swap & ZPool) are being created nor formatted. Not sure where the problem is, though I'm assuming I missed something, going to take another look at the documentation. I can either post the error here or make another issue, not sure if it's related or not.

vennsofar avatar Oct 09 '24 16:10 vennsofar

I'd say create a new issue because it's about a different kind of error. But yes, let's take a look at the logs together.

Just for clarification, which two fixes do you mean?

iFreilicht avatar Oct 09 '24 19:10 iFreilicht

To get back to the original issue:

When I change config.disko.devices to disko.devices it does work.

Where did you use config.disko.devices anyway? I'm wondering whether disko maybe isn't evaluating modules correctly in some cases.

iFreilicht avatar Oct 09 '24 19:10 iFreilicht

I used both your suggestion and @StijnRuts suggestion, as I wasnt sure if the decimal was causing any issues or not.

As for your fix, I just added config.disko to the disk top level attribute like this

{
  disko.devices.disk = {
    main = {
      type = "disk";
...

(where disko.devices.disk was originally just disk)

I'll make a new Issue for the other errors when I get a chance

vennsofar avatar Oct 09 '24 20:10 vennsofar