about summary refs log tree commit diff
path: root/pkgs/applications/system/zxfer/default.nix
blob: 802688cad5837efc0a88d9df50842b92896f67f3 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{ lib
, bash
, fetchFromGitHub
, installShellFiles
, coreutils
, gawk
, gnugrep
, gnused
, openssh
, resholve
, rsync
, which
, zfs
}:

resholve.mkDerivation rec {
  pname = "zxfer";
  version = "1.1.7";

  src = fetchFromGitHub {
    owner = "allanjude";
    repo = pname;
    rev = "v${version}";
    hash = "sha256-11SQJcD3GqPYBIgaycyKkc62/diVKPuuj2Or97j+NZY=";
  };

  nativeBuildInputs = [ installShellFiles ];

  # these may point to paths on remote systems, calculated at runtime, thus we cannot fix them
  # we can only set their initial values, and let them remain dynamic
  postPatch = ''
    substituteInPlace zxfer \
      --replace 'LCAT=""'                'LCAT=${coreutils}/bin/cat' \
      --replace 'LZFS=$( which zfs )'    'LZFS=${zfs}/bin/zfs'
  '';

  installPhase = ''
    runHook preInstall

    installManPage zxfer.1m zxfer.8
    install -Dm755 zxfer -t $out/bin/

    runHook postInstall
  '';

  solutions.default = {
    scripts = [ "bin/zxfer" ];
    interpreter = "${bash}/bin/sh";
    inputs = [
      coreutils
      gawk
      gnugrep
      gnused
      openssh
      rsync
      which
    ];
    fake.external = [
      "kldload" # bsd builtin
      "kldstat" # bsd builtin
      "svcadm" # solaris builtin
    ];
    keep = {
      "$LCAT" = true;
      "$LZFS" = true;
      "$PROGRESS_DIALOG" = true;
      "$RZFS" = true;
      "$input_optionts" = true;
      "$option_O" = true;
      "$option_T" = true;
    };
    fix = {
      "$AWK" = [ "awk" ];
      "$RSYNC" = [ "rsync" ];
    };
    execer = [ "cannot:${rsync}/bin/rsync" ];
  };

  meta = with lib; {
    description = "Popular script for managing ZFS snapshot replication";
    homepage = "https://github.com/allanjude/zxfer";
    changelog = "https://github.com/allanjude/zxfer/releases/tag/v${version}";
    license = licenses.bsd2;
    maintainers = with lib.maintainers; [ urandom ];
    mainProgram = "zxfer";
  };
}