2021-07-26 10:06:06 +02:00
|
|
|
{ lib, stdenv, fetchFromGitHub, nixosTests, makeWrapper, zfs
|
2021-02-17 21:09:27 +01:00
|
|
|
, perlPackages, procps, which, openssh, mbuffer, pv, lzop, gzip, pigz }:
|
2019-10-27 04:33:32 +01:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "sanoid";
|
2023-07-20 19:37:12 +02:00
|
|
|
version = "2.2.0";
|
2019-10-27 04:33:32 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "jimsalterjrs";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2023-07-20 19:37:12 +02:00
|
|
|
sha256 = "sha256-qfRGZ10fhLL4tJL97VHrdOkO/4OVpa087AsL9t8LMmk=";
|
2019-10-27 04:33:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
buildInputs = with perlPackages; [ perl ConfigIniFiles CaptureTiny ];
|
|
|
|
|
2021-07-26 10:06:06 +02:00
|
|
|
passthru.tests = nixosTests.sanoid;
|
|
|
|
|
2019-10-27 04:33:32 +01:00
|
|
|
installPhase = ''
|
2021-05-19 08:28:09 +02:00
|
|
|
runHook preInstall
|
|
|
|
|
2019-10-27 04:33:32 +01:00
|
|
|
mkdir -p "$out/bin"
|
|
|
|
mkdir -p "$out/etc/sanoid"
|
|
|
|
cp sanoid.defaults.conf "$out/etc/sanoid/sanoid.defaults.conf"
|
|
|
|
# Hardcode path to default config
|
|
|
|
substitute sanoid "$out/bin/sanoid" \
|
|
|
|
--replace "\$args{'configdir'}/sanoid.defaults.conf" "$out/etc/sanoid/sanoid.defaults.conf"
|
|
|
|
chmod +x "$out/bin/sanoid"
|
|
|
|
# Prefer ZFS userspace tools from /run/booted-system/sw/bin to avoid
|
|
|
|
# incompatibilities with the ZFS kernel module.
|
|
|
|
wrapProgram "$out/bin/sanoid" \
|
|
|
|
--prefix PERL5LIB : "$PERL5LIB" \
|
2021-08-09 11:56:58 +02:00
|
|
|
--prefix PATH : "${lib.makeBinPath [ procps "/run/booted-system/sw" zfs ]}"
|
2019-10-27 04:33:32 +01:00
|
|
|
|
|
|
|
install -m755 syncoid "$out/bin/syncoid"
|
|
|
|
wrapProgram "$out/bin/syncoid" \
|
|
|
|
--prefix PERL5LIB : "$PERL5LIB" \
|
2021-08-09 11:56:58 +02:00
|
|
|
--prefix PATH : "${lib.makeBinPath [ openssh procps which pv mbuffer lzop gzip pigz "/run/booted-system/sw" zfs ]}"
|
2019-10-27 04:33:32 +01:00
|
|
|
|
|
|
|
install -m755 findoid "$out/bin/findoid"
|
|
|
|
wrapProgram "$out/bin/findoid" \
|
|
|
|
--prefix PERL5LIB : "$PERL5LIB" \
|
2021-08-09 11:56:58 +02:00
|
|
|
--prefix PATH : "${lib.makeBinPath [ "/run/booted-system/sw" zfs ]}"
|
2021-05-19 08:28:09 +02:00
|
|
|
|
|
|
|
runHook postInstall
|
2019-10-27 04:33:32 +01:00
|
|
|
'';
|
|
|
|
|
2021-08-09 11:56:58 +02:00
|
|
|
meta = with lib; {
|
2019-10-27 04:33:32 +01:00
|
|
|
description = "Policy-driven snapshot management tool for ZFS filesystems";
|
|
|
|
homepage = "https://github.com/jimsalterjrs/sanoid";
|
2021-05-19 08:28:09 +02:00
|
|
|
license = licenses.gpl3Plus;
|
2023-07-20 19:45:21 +02:00
|
|
|
maintainers = with maintainers; [ lopsided98 Frostman ];
|
2019-10-27 04:33:32 +01:00
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
}
|