nixos-facter-modules
nixos-facter-modules copied to clipboard
Modules Structure: separate (nixos) config from options
trafficstars
When playing around with nixos-facter-modules i noticed that the files could be a bit optimized.
- somebody may want to import only the interface (options) but also would need to import all the nixos modules, because it sets config options in the same files.
# broadcom.nix
{ lib, config, ... }:
let
inherit (config.facter) report;
cfg = config.facter.networking.broadcom;
in
{
options.facter.networking.broadcom = with lib; {
# ...
};
config = {
hardware.enableRedistributableFirmware = lib.mkIf cfg.full_mac.enable (lib.mkDefault true);
boot = lib.mkIf cfg.sta.enable {
kernelModules = [ "wl" ];
extraModulePackages = [ config.boot.kernelPackages.broadcom_sta ];
};
};
}
@hsjobeki is it generally better practice to define options separately from config?
@hsjobeki is it generally better practice to define options separately from config?
Yes. I'd say so. But i havent seen any general recommendation ruleset. But that should be on it.
@brianmcgee
I use a nix file that generates a markdown doc based on all options.nix files in my repo. This is only possible because all of my options are defined separately from the configs. Could be one use-case of separation.