nixpkgs/pkgs/tools/backup/sanoid/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
1.9 KiB
Nix
Raw Normal View History

2021-07-26 08:06:06 +00:00
{ lib, stdenv, fetchFromGitHub, nixosTests, makeWrapper, zfs
2021-02-17 20:09:27 +00:00
, perlPackages, procps, which, openssh, mbuffer, pv, lzop, gzip, pigz }:
2019-10-27 03:33:32 +00:00
stdenv.mkDerivation rec {
pname = "sanoid";
version = "2.1.0";
2019-10-27 03:33:32 +00:00
src = fetchFromGitHub {
owner = "jimsalterjrs";
repo = pname;
rev = "v${version}";
sha256 = "12g5cjx34ys6ix6ivahsbr3bbbi1fmjwdfdk382z6q71w3pyxxzf";
2019-10-27 03:33:32 +00:00
};
nativeBuildInputs = [ makeWrapper ];
buildInputs = with perlPackages; [ perl ConfigIniFiles CaptureTiny ];
2021-07-26 08:06:06 +00:00
passthru.tests = nixosTests.sanoid;
2019-10-27 03:33:32 +00:00
installPhase = ''
runHook preInstall
2019-10-27 03:33:32 +00: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 09:56:58 +00:00
--prefix PATH : "${lib.makeBinPath [ procps "/run/booted-system/sw" zfs ]}"
2019-10-27 03:33:32 +00:00
install -m755 syncoid "$out/bin/syncoid"
wrapProgram "$out/bin/syncoid" \
--prefix PERL5LIB : "$PERL5LIB" \
2021-08-09 09:56:58 +00:00
--prefix PATH : "${lib.makeBinPath [ openssh procps which pv mbuffer lzop gzip pigz "/run/booted-system/sw" zfs ]}"
2019-10-27 03:33:32 +00:00
install -m755 findoid "$out/bin/findoid"
wrapProgram "$out/bin/findoid" \
--prefix PERL5LIB : "$PERL5LIB" \
2021-08-09 09:56:58 +00:00
--prefix PATH : "${lib.makeBinPath [ "/run/booted-system/sw" zfs ]}"
runHook postInstall
2019-10-27 03:33:32 +00:00
'';
2021-08-09 09:56:58 +00:00
meta = with lib; {
2019-10-27 03:33:32 +00:00
description = "A policy-driven snapshot management tool for ZFS filesystems";
homepage = "https://github.com/jimsalterjrs/sanoid";
license = licenses.gpl3Plus;
2019-10-27 03:33:32 +00:00
maintainers = with maintainers; [ lopsided98 ];
platforms = platforms.all;
};
}