Define and use NixOS module options within a flake.parts flake

Hello,

I’m reading about flake.parts and co for a while now and today I tried to setup a basic flake with utility commands for the shell and by now I’m more confused than convinced (very confused).

I started with a template and added packages (what worked). Then I tried to add nixosModules with options and config, like I previously did in a normal flake. But, the new options aren’t accessible from the config part so my configuration can’t react to eventual settings from the user.

I tried multiple paths using perSystem. ..., config.programs. … and many more but none of them worked, the attributes are always “not found“. I assume such modules should go into flake. too but I also tried it with perSystem.`.

(When in line 49 with cfg.rgv.enable it errors as config.programs in the let binding isn’t available.)

As I was unable to find documentation/examples/other questions about this I’m doubting right now if I really understood what flake.parts is for if it doesn’t work with configurable nixosModules/`homeModules`. So do I have to do something special for module options? Is there some special way for finding out the attribute path without asking? I tried nix repl but it was of no use for this problem.

Thanks in advance!
hc

EDIT:
This looks at least like someone wanted to achieve something similar but had no issue with this part: Using flake-parts, how to refer to `self.packages` from `flake.nixosModules`?

Finally I found a repository using this style and now it looks like it works (but it seems like documentation generation tools doesn’t understand it)

I’m unsure what was the important change but in the end I imported the following two files using imports and it worked.