aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/tools/backup/dirvish/default.nix
blob: c762da1a5fcb2adc37389ea29976d924497a73e7 (plain)
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
{ fetchurl, stdenv, makeWrapper, perl, perlPackages }:

stdenv.mkDerivation rec {
  name = "dirvish-1.2.1";
  src = fetchurl {
    url = "http://dirvish.org/${name}.tgz";
    sha256 = "6b7f29c3541448db3d317607bda3eb9bac9fb3c51f970611ffe27e9d63507dcd";
  };

  nativeBuildInputs = [ makeWrapper ];
  buildInputs = [ perl ] ++ (with perlPackages; [ GetoptLong TimeParseDate TimePeriod ]);

  executables = [ "dirvish" "dirvish-runall" "dirvish-expire" "dirvish-locate" ];
  manpages = [ "dirvish.8" "dirvish-runall.8" "dirvish-expire.8" "dirvish-locate.8" "dirvish.conf.5" ];

  buildPhase = ''
    HEADER="#!${perl}/bin/perl

    \$CONFDIR = \"/etc/dirvish\";

    "

    for executable in $executables; do
      (
        echo "$HEADER"
        cat $executable.pl loadconfig.pl
      ) > $executable
      chmod +x $executable
    done
  '';

  installPhase = ''
    mkdir -p $out/bin
    cp --target-directory=$out/bin $executables

    for manpage in $manpages; do
      if [[ $manpage =~ \.([[:digit:]]+)$ ]]; then
        section=''${BASH_REMATCH[1]}
        mkdir -p $out/man/man$section
        cp --target-directory=$out/man/man$section $manpage
      else
        echo "Couldn't determine man page section by filename"
        exit 1
      fi
    done
  '';

  postFixup = ''
    for executable in $executables; do
      wrapProgram $out/bin/$executable \
        --set PERL5LIB "$PERL5LIB"
    done
  '';

  meta = with stdenv.lib; {
    description = "Fast, disk based, rotating network backup system";
    homepage = "http://dirvish.org/";
    license = stdenv.lib.licenses.osl2;
    platforms = platforms.linux;
    maintainers = [ maintainers.winpat ];
  };
}