summary refs log tree commit diff
path: root/pkgs/applications/version-management/monotone/default.nix
blob: 34c3e611d40592cfba42a8d4899fcab70c7cc567 (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
{ lib, stdenv, fetchurl, fetchFromGitHub, boost, zlib, botan2, libidn
, lua, pcre, sqlite, perl, pkg-config, expect, less
, bzip2, gmp, openssl
, autoreconfHook, texinfo
}:

let
  version = "1.1-unstable-2021-05-01";
  perlVersion = lib.getVersion perl;
in

assert perlVersion != "";

stdenv.mkDerivation rec {
  pname = "monotone";
  inherit version;

  #  src = fetchurl {
  #    url = "http://monotone.ca/downloads/${version}/monotone-${version}.tar.bz2";
  #    sha256 = "124cwgi2q86hagslbk5idxbs9j896rfjzryhr6z63r6l485gcp7r";
  #  };

  # My mirror of upstream Monotone repository
  # Could fetchmtn, but circular dependency; snapshot requested
  # https://lists.nongnu.org/archive/html/monotone-devel/2021-05/msg00000.html
  src = fetchFromGitHub {
    owner = "7c6f434c";
    repo = "monotone-mirror";
    rev = "b30b0e1c16def043d2dad57d1467d5bfdecdb070";
    hash = "sha256:1hfy8vaap3184cd7h3qhz0da7c992idkc6q2nz9frhma45c5vgmd";
  };

  patches = [
    ./monotone-1.1-Adapt-to-changes-in-pcre-8.42.patch
    ./monotone-1.1-adapt-to-botan2.patch
  ];

  postPatch = ''
    sed -e 's@/usr/bin/less@${less}/bin/less@' -i src/unix/terminal.cc
  '';

  CXXFLAGS=" --std=c++11 ";

  nativeBuildInputs = [ pkg-config autoreconfHook texinfo ];
  buildInputs = [ boost zlib botan2 libidn lua pcre sqlite expect
    openssl gmp bzip2 perl ];

  postInstall = ''
    mkdir -p $out/share/${pname}-${version}
    cp -rv contrib/ $out/share/${pname}-${version}/contrib
    mkdir -p $out/${perl.libPrefix}/${perlVersion}
    cp -v contrib/Monotone.pm $out/${perl.libPrefix}/${perlVersion}

    patchShebangs "$out/share/monotone"
    patchShebangs "$out/share/${pname}-${version}"

    find "$out"/share/{doc/monotone,${pname}-${version}}/contrib/ -type f | xargs sed -e 's@! */usr/bin/@!/usr/bin/env @; s@! */bin/bash@!/usr/bin/env bash@' -i
  '';

  #doCheck = true; # some tests fail (and they take VERY long)

  meta = with lib; {
    description = "A free distributed version control system";
    maintainers = [ maintainers.raskin ];
    platforms = platforms.unix;
    license = licenses.gpl2Plus;
  };
}