Skip to content

inital work for finixModules#88

Draft
parzivale wants to merge 5 commits into
finix-community:mainfrom
parzivale:finix-modules
Draft

inital work for finixModules#88
parzivale wants to merge 5 commits into
finix-community:mainfrom
parzivale:finix-modules

Conversation

@parzivale

Copy link
Copy Markdown
Contributor

The idea behind this draft is to more clearly label finixModules as seperate from nixosModules to attempt to stop users to cross contaminating modules where possible, though any upstream nixos modules that does not set meta.class = "nixos" will still function with these changes

@parzivale

Copy link
Copy Markdown
Contributor Author

Ah it looks like I was mistaken its actually _class not meta.class but the other points still stand

@parzivale

parzivale commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

Potentially we could set up a seperate evalModules call with the class set to nixos to allow users to import nixos modules into their finix configuration

this would be a little hacky to setup but it would be the most reliable way to ensure finix users can import nixos modules at their discretion without allowing nixos users to import finix modules

something like

nixosModules = lib.evalModules {class = "nixos"; modules = [ <All collected nixos module imports>]};

then we could extract the evaluated config options to use in finix

nixosOptions accepts a list of NixOS modules whose option declarations
are made available inside the nixosModules submodule (evaluated with
class = "nixos"). The evaluated result is imported back into the finix
system so both option declarations and derived config propagate through.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@parzivale

parzivale commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

ok using this latest commit you should be able to register nixos modules for finix like so

 # modules/services/nginx.nix (a finix module)
  { pkgs, ... }: {
    nixosOptions = [
        "${pkgs.path}/nixos/modules/services/web-servers/nginx.nix"
    ];

    nixosModules = {
      services.nginx.enable = true;
      services.nginx.virtualHosts."example.com" = {
        root = "/var/www";
      };
    };
  }

Consolidates nixosOptions and nixosModules into a single nixos submodule
with nixos.options (list of NixOS option-declaring modules) and
nixos.config (submoduleWith class = "nixos" for configuration).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@parzivale

parzivale commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

ok slight changes now it looks like this

Module definition (a finix module that wraps a known-good NixOS module):

  # modules/services/nginx.nix
  { pkgs, ... }: {
    nixos.options = [
      "${pkgs.path}/nixos/modules/services/web-servers/nginx.nix"
    ];
  }

User implementation (a finix system using that module):

  # configuration.nix
  { pkgs... }: {
    imports = [ ./modules/services/nginx.nix ];

    nixos.config = {
      services.nginx.enable = true;
      services.nginx.virtualHosts."example.com" = {
        root = "/var/www";
      };
    };
  }

@parzivale

Copy link
Copy Markdown
Contributor Author

Im open to changing the naming as im not sure if what ive done makes sense but i think this is good for now

parzivale and others added 2 commits June 6, 2026 02:40
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@parzivale parzivale mentioned this pull request Jun 9, 2026
@parzivale

Copy link
Copy Markdown
Contributor Author

stalled until NixOS/nixpkgs#530003 is addressed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant