at 24.05-pre 56 lines 2.0 kB view raw
1{ lib, stdenv, fetchFromGitHub, nixosTests, makeWrapper, zfs 2, perlPackages, procps, which, openssh, mbuffer, pv, lzop, gzip, pigz }: 3 4stdenv.mkDerivation rec { 5 pname = "sanoid"; 6 version = "2.2.0"; 7 8 src = fetchFromGitHub { 9 owner = "jimsalterjrs"; 10 repo = pname; 11 rev = "v${version}"; 12 sha256 = "sha256-qfRGZ10fhLL4tJL97VHrdOkO/4OVpa087AsL9t8LMmk="; 13 }; 14 15 nativeBuildInputs = [ makeWrapper ]; 16 buildInputs = with perlPackages; [ perl ConfigIniFiles CaptureTiny ]; 17 18 passthru.tests = nixosTests.sanoid; 19 20 installPhase = '' 21 runHook preInstall 22 23 mkdir -p "$out/bin" 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 ]}" 35 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 ]}" 40 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 ]}" 45 46 runHook postInstall 47 ''; 48 49 meta = with lib; { 50 description = "A 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; 55 }; 56}