{ ... }: {
  flake.nixosModules.systemPackagesDefaults =
    { config, lib, pkgs, ... }:
    let
      cfg = config.chiasson.system;
    in
    {
      options.chiasson.system.defaultPackages = {
        enabled = lib.mkOption {
          type = lib.types.bool;
          default = true;
          description = "Enable shared default CLI/system package set.";
        };
        packages = lib.mkOption {
          type = lib.types.listOf lib.types.package;
          default = with pkgs; [
            git
            wget
            unzip
            jq
            ripgrep
            pfetch
          ];
          description = "Default packages to install on all hosts.";
        };
      };

      options.chiasson.system.extraPackages = lib.mkOption {
        type = lib.types.listOf lib.types.package;
        default = [ ];
        description = "Additional packages to install on all hosts.";
      };

      options.chiasson.system.allowUnfree = lib.mkOption {
        type = lib.types.bool;
        default = true;
        description = "Allow unfree packages from nixpkgs.";
      };

      config = lib.mkMerge [
        (lib.mkIf cfg.defaultPackages.enabled {
          environment.systemPackages = cfg.defaultPackages.packages;
        })
        (lib.mkIf (cfg.extraPackages != [ ]) {
          environment.systemPackages = cfg.extraPackages;
        })
        {
          nixpkgs.config.allowUnfree = cfg.allowUnfree;
        }
      ];
    };
}
