{ lib, inputs, nixpkgs, home-manager, user, configDir, ... }:

let
  system = "x86_64-linux";
  pkgs = import nixpkgs {
    inherit system;
    config.allowUnfree = true;
  };
  lib = nixpkgs.lib;
  hmImports = [
    (import ./home.nix)
  ];
  hmArgs = { inherit user configDir; };
in
{
  desktop = lib.nixosSystem {
    inherit system;
    specialArgs = { inherit user; };
    modules = [
      ./desktop
      ./configuration.nix
      ./desktop.nix
      {
        boot.loader.grub.gfxmodeEfi = "1920x1080";
        networking.hostName = "${user}";
      }
      home-manager.nixosModules.home-manager {
        home-manager = {
          useUserPackages = true;
          extraSpecialArgs = hmArgs;
          users.${user} = {
            imports = hmImports ++ [
              (import ./desktop/home.nix)
            ];
          };
        };
      }
    ];
  };


  x220 = lib.nixosSystem {
    inherit system;
    specialArgs = { inherit user; };
    modules = [
      ./thinkpads
      ./configuration.nix
      ./desktop.nix
      {
        # 1024x768 is the closest supported resolution to X220's native 1366x768
        # To see a list of supported GRUB resolutions, enter GRUB,
        # press e, F2 to enter command mode, and then type videoinfo to see list
        boot.loader.grub.gfxmodeEfi = "1024x768";
        networking.hostName = "x220";
      }
      home-manager.nixosModules.home-manager {
        home-manager = {
          useUserPackages = true;
          extraSpecialArgs = hmArgs;
          users.${user} = {
            imports = hmImports ++ [
              (import ./thinkpads/home.nix)
            ];
          };
        };
      }
    ];
  };

  t430 = lib.nixosSystem {
    inherit system;
    specialArgs = { inherit user; };
    modules = [
      ./thinkpads
      ./configuration.nix
      ./desktop.nix
      {
        boot.loader.grub.gfxmodeEfi = "1600x900";
        networking.hostName = "t430";
      }
      home-manager.nixosModules.home-manager {
        home-manager = {
          useUserPackages = true;
          extraSpecialArgs = hmArgs;
          users.${user} = {
            imports = hmImports ++ [
              (import ./thinkpads/home.nix)
            ];
          };
        };
      }
    ];
  };

  virtualbox = lib.nixosSystem {
    inherit system;
    specialArgs = { inherit user; };
    modules = [
      ./virtualbox
      ./configuration.nix
      ./desktop.nix
      {
        networking.hostName = "virtualbox";
      }
      home-manager.nixosModules.home-manager {
        home-manager = {
          useUserPackages = true;
          extraSpecialArgs = { inherit user; };
          users.${user} = {
            imports = hmImports ++ [
              (import ./virtualbox/home.nix)
            ];
          };
        };
      }
    ];
  };
}
