numtide / nixos-facter-modules

A series of NixOS modules to be used in conjunction with https://github.com/numtide/nixos-facter [maintainer=@numtide]
https://numtide.github.io/nixos-facter-modules/
MIT License
25 stars 3 forks source link

Modules Structure: separate (nixos) config from options #33

Open hsjobeki opened 2 weeks ago

hsjobeki commented 2 weeks ago

When playing around with nixos-facter-modules i noticed that the files could be a bit optimized.

# 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 ];
    };
  };

}
brianmcgee commented 5 days ago

@hsjobeki is it generally better practice to define options separately from config?

hsjobeki commented 5 days ago

@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.