@@ -0,0 +1,52 @@
1+{ stdenv, fetchurl, coreutils, bash, btrfs-progs, perl, perlPackages, makeWrapper }:
2+
3+stdenv.mkDerivation rec {
4+ name = "btrbk-${version}";
5+ version = "0.22.2";
6+
7+ src = fetchurl {
8+ url = "http://digint.ch/download/btrbk/releases/${name}.tar.xz";
9+ sha256 = "1gbgi0dp62wlw7y72pgxjs6byxkrk73g35kqxzw0gjf32r5i4sb8";
10+ };
11+
12+ patches = [
13+ # https://github.com/digint/btrbk/pull/74
14+ ./btrbk-Prefix-PATH-instead-of-resetting-it.patch
15+ # https://github.com/digint/btrbk/pull/73
16+ ./btrbk-mail-Use-btrbk-instead-of-unbound-variable-btr.patch
17+ ];
18+
19+ buildInputs = with perlPackages; [ makeWrapper perl DateCalc ];
20+
21+ preInstall = ''
22+ substituteInPlace Makefile \
23+ --replace "/usr" "$out" \
24+ --replace "/etc" "$out/etc"
25+
26+ # Tainted Mode disables PERL5LIB
27+ substituteInPlace btrbk --replace "perl -T" "perl"
28+
29+ # Fix btrbk-mail
30+ substituteInPlace contrib/cron/btrbk-mail \
31+ --replace "/bin/date" "${coreutils}/bin/date" \
32+ --replace "/bin/echo" "${coreutils}/bin/echo" \
33+ --replace '$btrbk' 'btrbk'
34+ '';
35+
36+ fixupPhase = ''
37+ patchShebangs $out/
38+
39+ wrapProgram $out/sbin/btrbk \
40+ --set PERL5LIB $PERL5LIB \
41+ --prefix PATH ':' "${btrfs-progs}/bin:${bash}/bin/"
42+ '';
43+
44+ meta = with stdenv.lib; {
45+ description = "A backup tool for btrfs subvolumes";
46+ homepage = http://digint.ch/btrbk;
47+ license = licenses.gpl3;
48+ platforms = platforms.unix;
49+ maintainers = with maintainers; [ the-kenny ];
50+ inherit version;
51+ };
52+}