{
  inputs,
  self,
  ...
}:
{
  flake.lib =
    let
      inherit (inputs.nixpkgs.lib) nixosSystem;
      inherit (builtins) mapAttrs;
      mkHost =
        {
          hostname,
          system,
          extraModules ? [ ],
          extraSpecialArgs ? { },
        }:
        nixosSystem {
          inherit system;
          specialArgs = {
            inherit inputs self;
          } // extraSpecialArgs;
          modules = [
            ../hosts/${hostname}
            self.nixosModules.default
            {
              _module.args = {
                lib' = self.lib;
                inherit system;
              };

              nixpkgs = {
                inherit system;
                config.allowUnfree = true;
              };
            }
            {
              networking.hostName = hostname;
              nix = {
                settings.extra-experimental-features = [
                  "nix-command"
                  "flakes"
                ];
                gc = {
                  automatic = true;
                  dates = "weekly";
                };
              };
              systemd.oomd = {
                enableRootSlice = true;
                extraConfig = {
                  DefaultMemoryPressureDurationSec = "20s";
                };
              };
            }
          ] ++ extraModules;
        };
      mkHosts = mapAttrs (hostname: args: mkHost (args // { inherit hostname; }));
    in
    {
      inherit mkHosts;
    };
}
