Importing a home-manager module from one flake to another

Hello! I’m having a hard time making use of a module that exists in my public flake (snowflake/modules/home-manager/fonts.nix at 0e21cdbf90498b136258f6f23bcb4c349b97439b · anthr76/snowflake · GitHub) to my private work flake.

I have my public flake defined as a input like so:

    snowflake.url = "github:anthr76/snowflake";
    snowflake.inputs.nixpkgs.follows = "nixpkgs";

My system is defined like:

        "sdfsdf@sdfasdfasdf" = lib.homeManagerConfiguration {
          pkgs = nixpkgs.legacyPackages.aarch64-darwin;
          extraSpecialArgs = { inherit inputs outputs; };
          modules = [
            # > Our main home-manager configuration file <
            ./home-manager/hosts/CW-R3C0W6YPWF-L.nix
            snowflake.homeManagerModules
          ];
        };

and I’m defined fontProfiles like:

{pkgs, ...}: {
  fontProfiles = {
    enable = true;
    monospace = {
      family = "JetBrains Mono Nerd Font";
      package = pkgs.nerdfonts.override { fonts = [ "JetBrainsMono" ]; };
    };
    regular = {
      family = "Fira Sans";
      package = pkgs.fira;
    };
  };
}

when I do a home-manager switch I get this error:

error:
       … while evaluating a branch condition

         at /nix/store/j10523yhkcc34478azkgcl70yzcx6j2j-source/lib/lists.nix:125:9:

          124|       fold' = n:
          125|         if n == len
             |         ^
          126|         then nul

       … while calling the 'length' builtin

         at /nix/store/j10523yhkcc34478azkgcl70yzcx6j2j-source/lib/lists.nix:123:13:

          122|     let
          123|       len = length list;
             |             ^
          124|       fold' = n:

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

       error: In module `<unknown-file>', you're trying to define a value of type `lambda'
       rather than an attribute set for the option
       `fonts'!

       This usually happens if `fonts' has option
       definitions inside that are not matched. Please check how to properly define
       this option by e.g. referring to `man 5 configuration.nix'!

Does anyone have any tips of what I can be doing wrong here?

This should work:

modules = [
  # > Our main home-manager configuration file <
  ./home-manager/hosts/CW-R3C0W6YPWF-L.nix
  snowflake.homeManagerModules.fonts
];

If you want to import more modules, consider exposing it as a list of imports in your flake:

homeManagerModules = {
  imports = [ 
    ./modules/fonts.nix 
    ./modules/something-else.nix 
  ];
};
1 Like

Wow that was a simple one! Thank you very much @gvolpe

1 Like