Rate-my-configs & Brainstorming: a "meta-module" to allow optional `import` into heterogenous modules

Rate my GitHub - nazarewk-iac/nix-configs: My Nix ecosystem journey, from the first commit to currently running configs

TLDR; I’m integrating more and more heterogeneous hardware from within a single repository, so:

  1. I split up modules into universal, shared and platform-specific pieces
  2. long time ago i wrote a custom thing to pass down into NixOS specialArgs as a kdn argument to integrate Raspberry Pi 4 hardware modules and differentiate NixOS installer iso from the rest of the modules,
    • I’m using it mostly for conditional import, so everything is optionally included as much as possible (I’m otherwise hiding everything behind *.enable flags in my own modules)
    • I was stuck with “infinite recursion” error on briv machine that I finally got to solve
  3. rewrote “the custom thing” into a module (in the commit)
  • I preserved the interface to limit the number of changes while solving the infinite recursion error
  • I’ll refactor/strip it down sometime in the next 50 years :stuck_out_tongue:

I have some vague ideas in the back of my head (some for years) to improve the stuff:

  1. the whole “folder-by-platform” is a disaster for navigating the related code, I would either:
    • fold it back to a single folder, while using <platform>.nix in role of default.nix
    • integrate the meta module more deeply with conditional (optionalAttrs / mkIf) configs within default.nix (or any other module).
  2. I’m thinking about pulling the modules/shared/universal into modules/meta, to define “what I need” separately from the implementation and make the boundary (painfully) obvious

What do you think about such setup? Any thought on maintainability and extendability of it?