Help exposing nixos module as flake

Hi,

I’ve been working on a NixOS module to implement declarative configuration for FireHol (https://firehol.org/) here: GitHub - TinHead/nixos-firehol: Firehol module for declarative NixOS firewall

Importing it directly in my configuration.nix works fine having the module locally available as below:

{
imports = [
   ./firehol/firhol.nix
];
#----snip---
services = {
  firehol = {
    enable = true;
   # declarative config below ....
  };

};
};

My trouble started when I have tried doing the same using flakes.
Below is my flake.nix for the module (no I have no idea what I’m doing here :slight_smile:):

{
   description = "firehole-nixos flake";
    inputs = {
      nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
    };
    outputs = { self, nixpkgs, ... }:
    {
       nixosModules = {
         nixos-firehol = import ./nixos-firehol.nix ;
       };
      nixosModule = self.nixosModules.nixos-firehol; # export single module
    };
 }

And my configuration flake:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
    sops-nix.url = github:Mic92/sops-nix;
    firehol-nixos.url = github:TinHead/nixos-firehol;
  };
  outputs = { nixpkgs, firehol-nixos, sops-nix, ... }: {
    colmena = {
      meta = {
        nixpkgs = import nixpkgs {
          system = "x86_64-linux";
        };
      };

      # Also see the non-Flakes hive.nix example above.
      myFirewallHost =[ ./firewall/configuration.nix sops-nix.nixosModules.sops];
    };
  };
}

And in ./firewall/configuration.nix:

{ config, pkgs, lib, firehol-nixos  , ... }:
# the usual config boot, network etc .... and finally services
services = {
   firehol = {
     enable = true;
     # configuration below ... 
   };
};

Building the above yells:

error: The option `services.firehol' does not exist. Definition values:
       - In `/nix/store/...../configuration.nix':
           {
             enable = true;
             interfaces = {
               esswg = {
                 myname = "vpn";
           ...
(use '--show-trace' to show detailed location information)
[ERROR] -----
[ERROR] Operation failed with error: Child process exited with error code: 1

So finally the question: What is the proper way to expose a module trough a flake?

Cheers,
Razvan

You have exposed it properly, though I can’t see where you import it in the consuming configuration.

OH! :man_facepalming:

....
myFirewallHost =[ ./firewall/configuration.nix sops-nix.nixosModules.sops firehol-nixos.nixosModules.nixos-firehol ];

That works! Not sure why it didn’t last night :man_shrugging: