summary refs log tree commit diff
path: root/pkgs/tools/backup/rsbep/default.nix
blob: 7f59b0af9444855556debff5021af97013b54953 (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
{ lib, stdenv, coreutils, gawk, fetchFromGitHub }:

stdenv.mkDerivation rec {
  pname = "rsbep";
  version = "0.2.0";

  src = fetchFromGitHub {
    owner = "ttsiodras";
    repo = "rsbep-backup";
    rev = "v${version}";
    sha256 = "0is4jgil3wdqbvx9h66xcyzbqy84ndyydnnay2g9k81a4mcz4dns";
  };

  postFixup = ''
    cd $out/bin

    # Move internal tool 'rsbep_chopper' to libexec
    libexecDir=$out/libexec/rsbep
    mkdir -p $libexecDir
    mv rsbep_chopper $libexecDir

    # Fix store dependencies in scripts
    path="export PATH=$out/bin:$libexecDir:${lib.makeBinPath [ coreutils gawk ]}"
    sed -i "2i$path" freeze.sh
    sed -i "2i$path" melt.sh

    # Remove unneded binary
    rm poorZFS.py
  '';

  doInstallCheck = true;
  installCheckPhase = ''
    cd $TMP
    echo hello > input
    $out/bin/freeze.sh input > packed
    $out/bin/melt.sh packed > output
    diff -u input output
  '';

  meta = with lib; {
    description = "Create resilient backups with Reed-Solomon error correction and byte-spreading";
    homepage = "https://www.thanassis.space/rsbep.html";
    license = licenses.gpl3Plus;
    maintainers = [ maintainers.earvstedt ];
  };
}