{ self, nixpkgs, ... }:
let
  inherit (self) inputs;

  common-intel = inputs.nixos-hardware.nixosModules.common-cpu-intel;
  common-nvidia = inputs.nixos-hardware.nixosModules.common-gpu-nvidia-nonprime;
  framework16 = inputs.nixos-hardware.nixosModules.framework-16-7040-amd;

  # mkHost := String -> Boolean -> [Attr] -> Attr - Create nixos system attribute set
  # @param name := String - Name of the system
  # @param useXLibre := Boolean - If set true, adds xlibre overlays to modules
  # @param machine := [Attr] - Array of attribute sets from nixos-hardware nixos Module for setting machine's preset
  # @return - An attribute set that describes NixOS system configurations

  mkHost = name: useXLibre: machine:
    nixpkgs.lib.nixosSystem {
      modules = [
        ./${name}
        ../overlays
      ] ++ builtins.attrValues self.nixosModules ++ (if useXLibre then [
        inputs.xlibre-overlay.nixosModules.overlay-xlibre-xserver
        inputs.xlibre-overlay.nixosModules.overlay-all-xlibre-drivers
      ] else []) ++ machine;

      specialArgs = {
        inherit inputs;
      };
    };
in
{
  "virtual-bird" = mkHost "virtual-bird" true [ common-intel ];
  "alanturing" = mkHost "alanturing" true [ common-intel common-nvidia ];
  "waku" = mkHost "waku" true [ framework16 ];
}
