{
  description = "Script to check for TLS appointments";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-21.11";
  };

  outputs = {self, nixpkgs, ...}: let
    system = "x86_64-linux";
    pkgs = nixpkgs.legacyPackages.${system};
  in {
    packages.${system}.matrix-nio = nixpkgs.legacyPackages.${system}.python3Packages.matrix-nio.overridePythonAttrs (old: {
      version = "0.20.2";

      src = pkgs.fetchFromGitHub {
        owner = "poljar";
        repo = "matrix-nio";
        rev = "0.20.2";
        hash = "sha256-opxYQZC6g2BvSk46/3Uf7UC2AMofYqLZ/v15X6YGqeU=";
      };

      checkInputs = [nixpkgs.legacyPackages.${system}.python3Packages.pytest-flake8];

      postPatch = ''
        rm -r tests
        mkdir -p tests

        echo 'def test_thing():' > tests/test_thing.py
        echo '    pass' >> tests/test_thing.py

        substituteInPlace pyproject.toml \
              --replace 'aiofiles = "^23.1.0"' 'aiofiles = "*"' \
              --replace 'aiohttp-socks = "^0.7.0"' 'aiohttp-socks = "*"' \
              --replace 'h11 = "^0.14.0"' 'h11 = "*"' \
              --replace 'jsonschema = "^4.4.0"' 'jsonschema = "*"' \
              --replace 'aiohttp = "^3.8.3"' 'aiohttp = "*"' \
              --replace 'cachetools = { version = "^4.2.1", optional = true }' 'cachetools = { version = "*", optional = true }'
      '';
    });

    devShells.${system}.default = pkgs.mkShell {
      packages = with pkgs; [
        geckodriver

        (python3.withPackages (ppkgs:
          with ppkgs; [
            self.packages.${system}.matrix-nio
            selenium

            python-lsp-server
            pyls-isort
            pylsp-mypy
            python-lsp-black
          ]))
      ];
    };
  };
}