1 { lib, stdenv, fetchFromGitHub, nixosTests, makeWrapper, zfs
2 , perlPackages, procps, which, openssh, mbuffer, pv, lzop, gzip, pigz }:
4 stdenv.mkDerivation rec {
8 src = fetchFromGitHub {
9 owner = "jimsalterjrs";
12 sha256 = "sha256-qfRGZ10fhLL4tJL97VHrdOkO/4OVpa087AsL9t8LMmk=";
15 nativeBuildInputs = [ makeWrapper ];
16 buildInputs = with perlPackages; [ perl ConfigIniFiles CaptureTiny ];
18 passthru.tests = nixosTests.sanoid;
24 mkdir -p "$out/etc/sanoid"
25 cp sanoid.defaults.conf "$out/etc/sanoid/sanoid.defaults.conf"
26 # Hardcode path to default config
27 substitute sanoid "$out/bin/sanoid" \
28 --replace "\$args{'configdir'}/sanoid.defaults.conf" "$out/etc/sanoid/sanoid.defaults.conf"
29 chmod +x "$out/bin/sanoid"
30 # Prefer ZFS userspace tools from /run/booted-system/sw/bin to avoid
31 # incompatibilities with the ZFS kernel module.
32 wrapProgram "$out/bin/sanoid" \
33 --prefix PERL5LIB : "$PERL5LIB" \
34 --prefix PATH : "${lib.makeBinPath [ procps "/run/booted-system/sw" zfs ]}"
36 install -m755 syncoid "$out/bin/syncoid"
37 wrapProgram "$out/bin/syncoid" \
38 --prefix PERL5LIB : "$PERL5LIB" \
39 --prefix PATH : "${lib.makeBinPath [ openssh procps which pv mbuffer lzop gzip pigz "/run/booted-system/sw" zfs ]}"
41 install -m755 findoid "$out/bin/findoid"
42 wrapProgram "$out/bin/findoid" \
43 --prefix PERL5LIB : "$PERL5LIB" \
44 --prefix PATH : "${lib.makeBinPath [ "/run/booted-system/sw" zfs ]}"
50 description = "Policy-driven snapshot management tool for ZFS filesystems";
51 homepage = "https://github.com/jimsalterjrs/sanoid";
52 license = licenses.gpl3Plus;
53 maintainers = with maintainers; [ lopsided98 Frostman ];
54 platforms = platforms.all;