Nix Flake Module Import Error

Hi all,

I’m working on packaging a python project and making it available as a NixOS module.
You can find the flake file on github.

And here’s how I use the flake as input for another flake file:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
    nix-bitcoin.url = "github:fort-nix/nix-bitcoin";
    blitz-api.url = "github:fusion44/blitz_api/nixosify";
  };
  outputs = inputs @ {
    self,
    nixpkgs,
    nix-bitcoin,
    blitz-api,
    ...
  }: {
    nixosConfigurations.tbnix = nixpkgs.lib.nixosSystem {
      system = "aarch64-linux";
      modules = [
        nix-bitcoin.nixosModules.default
        blitz-api.nixosModules.default
        ./configuration.nix
      ];
    };
  };
}

When I try to import the flake as another flakes input then I get the message that the nixosModules.default attribute is missing.

         at /nix/store/7q4y8idjk2di380j1fxn4k7wx9y935cl-source/lib/trivial.nix:448:16:

          447|   */
          448|   isFunction = f: builtins.isFunction f ||
             |                ^
          449|     (f ? __functor && isFunction (f.__functor f));

       error: attribute 'default' missing

       at /nix/store/7hw70pjn4fxf4xydamr8m3czafkwkzv1-source/flake.nix:18:9:

           17|         nix-bitcoin.nixosModules.default
           18|         blitz-api.nixosModules.default
             |         ^
           19|         ./configuration.nix

I can’t find any obvious problem with the way I set things up.

Put the NixOS modules outside the flake-utils.lib.eachDefaultSystem function. If you put a nixosModules.default attribute inside it, it ends up being nixosModules."<system>".default.

1 Like

Yes, this did the trick. Having different kinds of errors now, but they seem solvable. Thank you!