summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/django-auditlog/default.nix
blob: ca505c3114e08012e66a21a79febc4301b9d25af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,
  setuptools,
  setuptools-scm,
  django,
  python-dateutil,
  freezegun,
  psycopg2,
  postgresql,
  postgresqlTestHook,
  python,
}:

buildPythonPackage rec {
  pname = "django-auditlog";
  version = "3.3.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "jazzband";
    repo = "django-auditlog";
    tag = "v${version}";
    hash = "sha256-ZOCLlS9SUY8W3jfA+51gy5yUchJr+rpBzH+Sx1G/kUM=";
  };

  nativeBuildInputs = [
    setuptools
    setuptools-scm
  ];

  propagatedBuildInputs = [
    django
    python-dateutil
  ];

  nativeCheckInputs = [
    freezegun
    psycopg2
    postgresql
    postgresqlTestHook
  ];

  doCheck = stdenv.hostPlatform.isLinux; # postgres fails to allocate shm on darwin

  postgresqlTestUserOptions = "LOGIN SUPERUSER";

  checkPhase = ''
    runHook preCheck

    cd auditlog_tests
    # strip escape codes otherwise tests fail
    # see https://github.com/jazzband/django-auditlog/issues/644
    TEST_DB_USER=$PGUSER \
    TEST_DB_HOST=$PGHOST \
    ${python.interpreter} ./manage.py test | cat
    cd ..

    runHook postCheck
  '';

  pythonImportsCheck = [ "auditlog" ];

  meta = {
    changelog = "https://github.com/jazzband/django-auditlog/blob/${src.tag}/CHANGELOG.md";
    description = "Django app that keeps a log of changes made to an object";
    downloadPage = "https://github.com/jazzband/django-auditlog";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ leona ];
  };
}