{ pkgs ? import <nixpkgs> {} }:
with pkgs.python313Packages;

let
  sources = import ./npins;
  pywikiapi = buildPythonPackage rec {
    pname = "pywikiapi";
    version = "pinned";
    src = sources.pywikiapi;

    dependencies = [
      requests
    ];
  };
  logformat = import "${sources.logformat}" {};
in
buildPythonApplication rec {
  pname = "osm-proposals";
  version = "git";
  src = ./.;
  pyproject = true;

  build-system = [
    hatchling
  ];

  dependencies = [
    requests
    mwparserfromhell
    pywikiapi
    logformat
  ];

  # smoke test
  preCheck = "$out/bin/osm-proposals --help >/dev/null";

  postInstall = ''
    mkdir -p $out/share/osm-proposals
    cp -r ${./static}/. $out/share/osm-proposals/
  '';

  nativeCheckInputs = [
    pytestCheckHook
  ];
}