Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All suites return "attribute missing" #282

Closed
ymarkus opened this issue May 15, 2021 · 8 comments
Closed

All suites return "attribute missing" #282

ymarkus opened this issue May 15, 2021 · 8 comments
Labels
APIv1 related to 1.0 api stabilization bug Something isn't working

Comments

@ymarkus
Copy link
Contributor

ymarkus commented May 15, 2021

After pulling the latest commits from the core branch, all my suites defined in profiles/suites.nix return an "attribute missing error".

Current Behavior

hosts/whatever.nix:

{ hardware, suites, ... }:

{
  imports = [
    ./whatever/hardware.nix
    hardware.whatever
  ] ++ suites.laptop ++ suites.gaming ++ suites.virt;
  [...]
}

trying to build it:

❯ sudo nixos-rebuild --flake ".#whatever" boot
building the system configuration...
error: attribute 'laptop' missing

       at /nix/store/ls9kilcc14yxbci68xmaxn67ww6n6j7l-source/hosts/whatever.nix:7:8:

            6|     hardware.whatever
            7|   ] ++ suites.laptop ++ suites.gaming ++ suites.virt;
             |        ^
            8|
(use '--show-trace' to show detailed location information)

Possible Solution

There seems to be a suites definition in default.nix now, is that supposed to be used from now on? Then the documentation has to be updated!
OK, it seems the documentation does say to use the namespaces for nixos and home, but the issue there is that you can't use rec and that makes it quite messy.

Steps to Reproduce

  1. Define suites in profile/suites.nix
  2. Try to use those suites in host
@ymarkus ymarkus added the bug Something isn't working label May 15, 2021
@blaggacao
Copy link
Contributor

blaggacao commented May 15, 2021

We recently did quite a big refactoring in order to navigate the whole project into less choppy future waters.

On behalf of the involved parties, I apologize for the troubles caused.


Suites where such a "shallow" abstraction that, in order to provide a better overview of a particular devos environment, we decided to define them directly in flake.nix.

Think of "table of content".

Of course, they can be kept in their own file, but the suite's function signature has to mirror the files fed to profiles from now on. That is true for both subsystems, where suites are in use: home & nixos.


Example following. Note, how the suite's function signature matches the folder names passed to profiles: that is (magic) by design.

{
        profiles = [ ./profiles ./users ];
        suites = { profiles, users, ... }: with profiles; {
          base = [ core users.nixos users.root ];
        };
}

Please let me know, if I can help you out in any other way.

@Pacman99
Copy link
Member

Pacman99 commented May 15, 2021

the issue there is that you can't use rec and that makes it quite messy.

I'm pretty sure you can use rec. I use it in my repo. Was there an issue when you used it? We should probably add rec to the flake.nix.

@blaggacao blaggacao added the APIv1 related to 1.0 api stabilization label May 16, 2021
@ymarkus
Copy link
Contributor Author

ymarkus commented May 18, 2021

@blaggacao Thanks for the detailed explanation. I actually like the changes you're implementing, that's why I pull them into my repo! I just think the documentation could have a little more information. I'll have a look at adding it.

I'm pretty sure you can use rec. I use it in my repo. Was there an issue when you used it? We should probably add rec to the flake.nix.

If I try to use it this way:

suites = { profiles, users, ... }: with profiles; rec {
[...]
};

I get:

❯ sudo nixos-rebuild --flake ".#whatever" boot
building the system configuration...
error: infinite recursion encountered

       at /nix/store/8xvwfm02dicgbpkyyaqi0961nd01r8g0-source/lib/modules.nix:305:28:

          304|         builtins.addErrorContext (context name)
          305|           (args.${name} or config._module.args.${name})
             |                            ^
          306|       ) (lib.functionArgs f);
(use '--show-trace' to show detailed location information)

@Pacman99
Copy link
Member

Ohh that seems to be a different problem. It looks to be a module system infinite recursion error. That is usually unrelated to rec. Can you post the full stack trace, that should help me figure out exactly where it is.

Generally it happens when you try to use a module argument in an imports line or you ask for too many arguments in a module. Keep in mind your flake.nix is now a module since that's how we now evaluate arguments passed to digga. So it could be happening somewhere there.

rec could be triggering it somehow, but I don't think this error is actually because of rec.

@blaggacao
Copy link
Contributor

blaggacao commented May 18, 2021

@ymarkus Can you also post your current suites stanza from the flake.nix — or a minimal example that reproduces the error? Just in case. It might help a little to find a solution quickly.

@ymarkus
Copy link
Contributor Author

ymarkus commented May 18, 2021

I think I have found the error: my host looks like this:

{ hardware, suites, ... }:

{
  imports = [
    ./whatever/hardware.nix
    hardware.lenovo-thinkpad-x1-6th-gen
  ] ++ suites.mobileWS ++ suites.gaming ++ suites.virt;
  ...
}

If I remove the hardware references, it works. I'll move those to the flake.nix file. But the documentation is wrong. Where it says:

{
  nixos.hosts = mkMerge [
    (devos.lib.importHosts ./hosts)
    {
      librem = {
        channelName = "latest";
        modules = [ hardware.purism-librem-13v3 ];
      };
    }
  ];
}

it should rather be:

{
  nixos.hosts = mkMerge [
    (devos.lib.importHosts ./hosts)
    {
      librem = {
        channelName = "latest";
        modules = [ nixos-hardware.nixosModules.purism-librem-13v3 ];
      };
    }
  ];
}

@ymarkus
Copy link
Contributor Author

ymarkus commented May 18, 2021

Thanks for your help and sorry to bother. As soon as the documentation is fixed, we can close this!

Edit: And BTW, can we please remove the file profiles/suites.nix from this repo? It is a bit confusing...

bors bot added a commit that referenced this issue May 18, 2021
291: Remove ´profiles/suites.nix` and fix hardware module in hosts documentation r=blaggacao a=ymarkus

See #282 

As I understand it, this file isn't needed anymore and the hardware module is not defined properly in the documentation.

Co-authored-by: Yannick Markus <ym@ymarkus.dev>
@ymarkus
Copy link
Contributor Author

ymarkus commented May 20, 2021

Ok, thanks for the help everyone!

@ymarkus ymarkus closed this as completed May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
APIv1 related to 1.0 api stabilization bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants