flakelight icon indicating copy to clipboard operation
flakelight copied to clipboard

Am I trying to use home-manager modules wrong in a nixosConfiguration?

Open mitchty opened this issue 8 months ago • 0 comments

I tried to set this all up in a minimal reproducer/example. I have things working similarly in Darwin fine so bit confused where things are failing here as I'm not sure exactly where the nesting is coming from when using any home-manager.users.user = {}.

But to get to the point https://github.com/mitchty/nix/blob/fl-hm/nix/nixosConfigurations/hm/default.nix gives me this fun error when running nix flake check:

$ nix flake check                                                                                            ~/src/pub/github.com/mitchty/nix@fl-hm mbp
warning: Git tree '/Users/mitch/src/pub/github.com/mitchty/nix@fl-hm' is dirty
error:
       … while checking flake output 'nixosConfigurations'

       … while checking the NixOS configuration 'nixosConfigurations.hm'

       … while calling the 'head' builtin
         at /nix/store/a4lkx9hmv2099n6p1rkzxm481hfw7pwr-source/lib/attrsets.nix:1534:13:
         1533|           if length values == 1 || pred here (elemAt values 1) (head values) then
         1534|             head values
             |             ^
         1535|           else

       … while evaluating the option `system.build.toplevel':

       … while evaluating definitions from `/nix/store/a4lkx9hmv2099n6p1rkzxm481hfw7pwr-source/nixos/modules/system/activation/top-level.nix':

       … while evaluating the option `assertions':

       … while evaluating definitions from `/nix/store/rhr49ka75i442hzxygbdx1psfdh5plgj-source/nixos/common.nix':

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

       error: Module imports can't be nested lists. Perhaps you meant to remove one level of lists? Definitions:
       - In `/nix/store/rhr49ka75i442hzxygbdx1psfdh5plgj-source/nixos/common.nix':
           [
             {
               imports = [
                 <function, args: {config, lib, options, pkgs}>
               ];
           ...
zsh: exit 1     nix flake check

I tried setting up a top level home manager configuration too and import that as the user but keep hitting this nested module import error.

I'll note Darwin worked fine doing basically what I expected ref https://github.com/mitchty/nix/blob/shenanigans/nix/darwinConfigurations/mbp/default.nix#L23-L30

      home-manager.users.mitch = {
        imports = with inputs.self.homeModules; [
          emacs
          development
          gui
          macos
          mutagen
        ];

Curious if you've any idea where the import nesting may be happening? I got halfway through the stack traces and am taking a bit of a break for a bit and thought I'd ping here and see if anyone that knows a skosh more has an idea or better usage example. I tried sharedModules to see if I got other outputs but it seems to be in the home-manager module itself I think and maybe also related to how flake light is importing it.

mitchty avatar May 18 '25 16:05 mitchty