about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/misc/gramps/default.nix
blob: 7539b22087c34d875817686bea803a8afb812a26 (plain) (blame)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
{ lib
, fetchpatch
, fetchFromGitHub
, gtk3
, pythonPackages
, glibcLocales
, intltool
, gexiv2
, pango
, gobject-introspection
, wrapGAppsHook
, gettext
, # Optional packages:
  enableOSM ? true
, osm-gps-map
, glib-networking
, enableGraphviz ? true
, graphviz
, enableGhostscript ? true
, ghostscript
}:

let
  inherit (pythonPackages) python buildPythonApplication;
in
buildPythonApplication rec {
  version = "5.1.6";
  pname = "gramps";
  pyproject = true;

  nativeBuildInputs = [
    wrapGAppsHook
    intltool
    gettext
    gobject-introspection
    pythonPackages.setuptools
  ];

  nativeCheckInputs = [
    glibcLocales
    pythonPackages.jsonschema
    pythonPackages.mock
    pythonPackages.lxml
  ];

  buildInputs = [ gtk3 pango gexiv2 ]
    # Map support
    ++ lib.optionals enableOSM [ osm-gps-map glib-networking ]
    # Graphviz support
    ++ lib.optional enableGraphviz graphviz
    # Ghostscript support
    ++ lib.optional enableGhostscript ghostscript
  ;

  src = fetchFromGitHub {
    owner = "gramps-project";
    repo = "gramps";
    rev = "v${version}";
    hash = "sha256-BerkDXdFYfZ3rV5AeMo/uk53IN2U5z4GFs757Ar26v0=";
  };

  pythonPath = with pythonPackages; [
    bsddb3
    pyicu
    pygobject3
    pycairo
  ];

  patches = [
    # fix for running tests with a temporary home - remove next release
    # https://gramps-project.org/bugs/view.php?id=12577
    (fetchpatch {
      url = "https://github.com/gramps-project/gramps/commit/1e95d8a6b5193d655d8caec1e6ab13628ad123db.patch";
      hash = "sha256-2riWB13Yl+tk9+Tuo0YDLoxY2Rc0xrJKfb+ZU7Puzxk=";
    })
  ];

  # Same installPhase as in buildPythonApplication but without --old-and-unmanageble
  # install flag.
  installPhase = ''
    runHook preInstall

    mkdir -p "$out/${python.sitePackages}"

    export PYTHONPATH="$out/${python.sitePackages}:$PYTHONPATH"

    ${python}/bin/${python.executable} setup.py install \
      --install-lib=$out/${python.sitePackages} \
      --prefix="$out"

    eapth="$out/${python.sitePackages}/easy-install.pth"
    if [ -e "$eapth" ]; then
        # move colliding easy_install.pth to specifically named one
        mv "$eapth" $(dirname "$eapth")/${pname}-${version}.pth
    fi

    rm -f "$out/${python.sitePackages}"/site.py*

    runHook postInstall
  '';

  preCheck = ''
    export HOME=$TMPDIR
  '';

  # https://github.com/NixOS/nixpkgs/issues/149812
  # https://nixos.org/manual/nixpkgs/stable/#ssec-gnome-hooks-gobject-introspection
  strictDeps = false;

  meta = with lib; {
    description = "Genealogy software";
    homepage = "https://gramps-project.org";
    maintainers = with maintainers; [ jk pinpox ];
    changelog = "https://github.com/gramps-project/gramps/blob/v${version}/ChangeLog";
    longDescription = ''
      Every person has their own story but they are also part of a collective
      family history. Gramps gives you the ability to record the many details of
      an individual's life as well as the complex relationships between various
      people, places and events. All of your research is kept organized,
      searchable and as precise as you need it to be.
    '';
    license = licenses.gpl2Plus;
  };
}