{ flake-inputs }:
let
  inherit (flake-inputs.nixpkgs) lib;
  pkgs = flake-inputs.nixpkgs.legacyPackages.x86_64-linux;
  checkLib = pkgs.callPackage ./lib.nix { };
in
{
  x86_64-linux = lib.mergeAttrsList [
    flake-inputs.self.nixosConfigurations.hetzner-1.config.serviceTests

    {
      nix = checkLib.mkLint {
        name = "nix-lints";
        fileset = lib.fileset.fileFilter (file: file.hasExt "nix") ../.;

        checkInputs = lib.attrValues {
          inherit (pkgs) deadnix nixfmt-rfc-style;

          statix = pkgs.statix.overrideAttrs (old: {
            patches = old.patches ++ [
              (pkgs.fetchpatch {
                url = "https://github.com/oppiliappan/statix/commit/925dec39bb705acbbe77178b4d658fe1b752abbb.patch";
                hash = "sha256-0wacO6wuYJ4ufN9PGucRVJucFdFFNF+NoHYIrLXsCWs=";
              })
            ];
          });
        };

        script = ''
          statix check **/*.nix
          deadnix --fail **/*.nix
          nixfmt --check --strict **/*.nix
        '';
      };

      lockfile = checkLib.mkLint {
        name = "nix-lockfile";
        fileset = ../flake.lock;
        checkInputs = lib.attrValues { inherit (flake-inputs.flint.packages.x86_64-linux) flint; };

        script = ''
          flint --fail-if-multiple-versions
        '';
      };
    }
  ];
}
