1{ stdenv, buildPythonPackage, isPy3k, fetchFromGitHub, fetchpatch
2, utillinux, pygit2, gitMinimal, git-annex
3}:
4
5buildPythonPackage rec {
6 pname = "git-annex-adapter";
7 version = "0.2.0";
8
9 disabled = !isPy3k;
10
11 # There is only a wheel on PyPI - build from source instead
12 src = fetchFromGitHub {
13 owner = "alpernebbi";
14 repo = pname;
15 rev = "v${version}";
16 sha256 = "1sbgp4ivgw4m8nngrlb1f78xdnssh639c1khv4z98753w3sdsxdz";
17 };
18
19 prePatch = ''
20 substituteInPlace git_annex_adapter/process.py \
21 --replace "'git', 'annex'" "'${git-annex}/bin/git-annex'" \
22 --replace "'git-annex'" "'${git-annex}/bin/git-annex'"
23 '';
24
25 patches = [
26 # fixes the "not-a-git-repo" testcase where recent git versions expect a slightly different error.
27 ./not-a-git-repo-testcase.patch
28
29 # fixes the testcase which parses the output of `git-annex info` where several
30 # new lines are displayed that broke the test.
31 (fetchpatch {
32 url = "https://github.com/Ma27/git-annex-adapter/commit/39cb6da69c1aec3d57ea9f68c2dea5113ae1b764.patch";
33 sha256 = "0wyy2icqan3jpiw7dm50arfq3mgq4b5s3g91k82srap763r9hg5m";
34 })
35
36 # fixes the testcase which runs "git status" and complies with the
37 # slightly altered output.
38 (fetchpatch {
39 url = "https://github.com/alpernebbi/git-annex-adapter/commit/9f64c4b99cae7b681820c6c7382e1e40489f4d1e.patch";
40 sha256 = "0yh66gial6bx7kbl7s7lkzljnkpgvgr8yahqqcq9z76d0w752dir";
41 })
42 ] ++ stdenv.lib.optionals stdenv.isDarwin [
43 # `rev` is part of utillinux on NixOS which is not available on `nixpks` for darwin:
44 # https://logs.nix.ci/?key=nixos/nixpkgs.45061&attempt_id=271763ba-2ae7-4098-b469-b82b1d8edb9b
45 (fetchpatch {
46 url = "https://github.com/alpernebbi/git-annex-adapter/commit/0b60b4577528b309f6ac9d47b55a00dbda9850ea.patch";
47 sha256 = "0z608hpmyzv1mm01dxr7d6bi1hc77h4yafghkynmv99ijgnm1qk7";
48 })
49 ];
50
51 checkInputs = [
52 utillinux # `rev` is needed in tests/test_process.py
53 ];
54
55 propagatedBuildInputs = [ pygit2 gitMinimal ];
56
57 buildInputs = [ git-annex ];
58
59 checkPhase = ''
60 python -m unittest
61 '';
62
63 meta = with stdenv.lib; {
64 homepage = https://github.com/alpernebbi/git-annex-adapter;
65 description = "Call git-annex commands from Python";
66 license = licenses.gpl3Plus;
67 maintainers = with maintainers; [ dotlambda ma27 ];
68 };
69}