1{ lib, stdenv, fetchFromGitHub, coreutils, installShellFiles }:
2
3stdenv.mkDerivation rec {
4 version = "2.0.0-beta3";
5 pname = "zfsnap";
6
7 src = fetchFromGitHub {
8 owner = "zfsnap";
9 repo = "zfsnap";
10 rev = "v${version}";
11 sha256 = "0670a5sghvqx32c9gfsird15mg9nqcvwxsrfcjrwc0sj7br9bd2g";
12 };
13
14 nativeBuildInputs = [ installShellFiles ];
15
16 postPatch = ''
17 # Use zfs binaries from PATH, because often the zfs package from nixpkgs is
18 # not the one that should be used
19 substituteInPlace share/zfsnap/core.sh \
20 --replace "ZFS_CMD='/sbin/zfs'" "ZFS_CMD='zfs'" \
21 --replace "ZPOOL_CMD='/sbin/zpool'" "ZPOOL_CMD='zpool'"
22
23 substituteInPlace sbin/zfsnap.sh \
24 --replace "/bin/ls" "${coreutils}/bin/ls"
25 '';
26
27 installPhase = ''
28 mkdir -p $out/bin
29 mv sbin/zfsnap.sh $out/bin/zfsnap
30 mv share $out
31 installManPage man/*/*
32 installShellCompletion completion/*.{bash,zsh}
33 '';
34
35 meta = with lib; {
36 description = "A portable, performant script to make rolling ZFS snapshots easy";
37 homepage = "https://github.com/zfsnap/zfsnap";
38 license = licenses.bsd3;
39 maintainers = with maintainers; [ woffs ];
40 platforms = platforms.linux;
41 };
42}