Stream: nixos

Topic: module class error


view this post on Zulip Arul Agrawal (Dec 08 2025 at 13:32):

Hey all, I recently tried to update my system nix flake after a few months, and ran into an issue I haven't been able to find much about:

          419|               The module `${m._file or m.key}` (class: ${lib.strings.escapeNixString m._class}) cannot be imported into a module evaluation that expects class ${lib.strings.escapeNixString class}.

       error: The module `/nix/store/xm3nq4fadri4jcc3ms6vhc4nx5rgi27z-source/flake.nix#nixosModules.common` (class: "nixos") cannot be imported into a module evaluation that expects class "darwin".

       Help:
       - Ensure that you are importing the correct module.
       - Verify that the module's `_class`, "nixos" matches the expected `class` "darwin".
       - If you are using a custom class, make sure it is correctly defined and used consistently across your modules.

Here is my current flake: https://github.com/arulagrawal/nix/blob/fixing/flake.nix
The only thing I did was run nix flake update (no config changes) so I'm not really sure where things changed.
Any help appreciated!!

view this post on Zulip Srid (Dec 08 2025 at 17:43):

Probably coming from new flake-parts.

Don't run nix flake update. Instead only update the relevant inputs (nixpkgs, nix-darwin, home-manager, etc.) by passing them as arguments.

view this post on Zulip Srid (Dec 08 2025 at 17:46):

And since you use nixos-unified:

image.png


Last updated: Dec 25 2025 at 08:28 UTC