lol
1{ stdenv, fetchurl, coreutils, bash, btrfs-progs, openssh, perl, perlPackages
2, utillinux, asciidoc, makeWrapper }:
3
4stdenv.mkDerivation rec {
5 name = "btrbk-${version}";
6 version = "0.26.1";
7
8 src = fetchurl {
9 url = "https://digint.ch/download/btrbk/releases/${name}.tar.xz";
10 sha256 = "04ahfm52vcf1w0c2km0wdgj2jpffp45bpawczmygcg8fdcm021lp";
11 };
12
13 nativeBuildInputs = [ asciidoc makeWrapper ];
14
15 buildInputs = with perlPackages; [ perl DateCalc ];
16
17 preInstall = ''
18 for f in $(find . -name Makefile); do
19 substituteInPlace "$f" \
20 --replace "/usr" "$out" \
21 --replace "/etc" "$out/etc"
22 done
23
24 # Tainted Mode disables PERL5LIB
25 substituteInPlace btrbk --replace "perl -T" "perl"
26
27 # Fix btrbk-mail
28 substituteInPlace contrib/cron/btrbk-mail \
29 --replace "/bin/date" "${coreutils}/bin/date" \
30 --replace "/bin/echo" "${coreutils}/bin/echo" \
31 --replace '$btrbk' 'btrbk'
32
33 # Fix SSH filter script
34 sed -i '/^export PATH/d' ssh_filter_btrbk.sh
35 substituteInPlace ssh_filter_btrbk.sh --replace logger ${utillinux}/bin/logger
36 '';
37
38 preFixup = ''
39 wrapProgram $out/sbin/btrbk \
40 --set PERL5LIB $PERL5LIB \
41 --prefix PATH ':' "${stdenv.lib.makeBinPath [ btrfs-progs bash openssh ]}"
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}