flyingcircusio / batou_ext

A library of batou extensions.
Other
4 stars 1 forks source link

Ideas for improvements of the NixOS module components #150

Open Ma27 opened 8 months ago

Ma27 commented 8 months ago

This issue gathers a few ideas I had in mind about batou_ext.nixos.NixOSModule. We talked about the location topic already, but I'd like to have these written down somewhere.

Location of .nix files

The actual Nix expression is now in /srv/s-service/deployment/component rather than /etc/local/nixos. This is not only unexpected (until now one could be sure that everything from AppOps is in /etc/local/nixos), it's also harder to grep for certain patterns in the NixOS configuration on the live system.

JSON vs Nix

I'm wondering if we should rather transform the entire tree into JSON rather than Nix:

component vs _module.args

The attributes from a component are handed in like this:

{ pkgs, lib, config # from config._module.args
, component # from the Nix file importing this specific file
, ...
}:

The problem I see here is that the arguments in the attribute-set that each module function gets is the value of the option _module.args, we however inject a custom value and bypass the module system which seems unintuitive for people being used to write NixOS modules. Also, we potentially shadow values in _module.args because of //. Generally I'm not sure if we're hitting issues eventually with that now that we leave the path of what's supported and what the module system itself expects.

A common pattern is to define a tree with custom values in config, i.e. config.mydeployment.<...>. Perhaps we want to do something similar here? I.e. config.component.nginx.listen_port where nginx is a component for instance.