nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 104 lines 2.4 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 nixosTests, 6 makeWrapper, 7 zfs, 8 perlPackages, 9 procps, 10 which, 11 openssh, 12 mbuffer, 13 pv, 14 lzop, 15 gzip, 16 pigz, 17}: 18 19stdenv.mkDerivation rec { 20 pname = "sanoid"; 21 version = "2.3.0"; 22 23 src = fetchFromGitHub { 24 owner = "jimsalterjrs"; 25 repo = "sanoid"; 26 rev = "v${version}"; 27 sha256 = "sha256-s6MP3x4qSuuiJKq2V2oLAXp6zaMSqKRCs5O9UMSgcvE="; 28 }; 29 30 nativeBuildInputs = [ makeWrapper ]; 31 buildInputs = with perlPackages; [ 32 perl 33 ConfigIniFiles 34 CaptureTiny 35 ]; 36 37 passthru.tests = nixosTests.sanoid; 38 39 installPhase = '' 40 runHook preInstall 41 42 mkdir -p "$out/bin" 43 mkdir -p "$out/etc/sanoid" 44 cp sanoid.defaults.conf "$out/etc/sanoid/sanoid.defaults.conf" 45 # Hardcode path to default config 46 substitute sanoid "$out/bin/sanoid" \ 47 --replace "\$args{'configdir'}/sanoid.defaults.conf" "$out/etc/sanoid/sanoid.defaults.conf" 48 chmod +x "$out/bin/sanoid" 49 # Prefer ZFS userspace tools from /run/booted-system/sw/bin to avoid 50 # incompatibilities with the ZFS kernel module. 51 wrapProgram "$out/bin/sanoid" \ 52 --prefix PERL5LIB : "$PERL5LIB" \ 53 --prefix PATH : "${ 54 lib.makeBinPath [ 55 procps 56 "/run/booted-system/sw" 57 zfs 58 ] 59 }" 60 61 install -m755 syncoid "$out/bin/syncoid" 62 wrapProgram "$out/bin/syncoid" \ 63 --prefix PERL5LIB : "$PERL5LIB" \ 64 --prefix PATH : "${ 65 lib.makeBinPath [ 66 openssh 67 procps 68 which 69 pv 70 mbuffer 71 lzop 72 gzip 73 pigz 74 # /run/booted-system/sw/bin contains a sudo that does not work, so we need to override the override to use /run/wrappers/bin/sudo 75 "/run/wrappers" 76 "/run/booted-system/sw" 77 zfs 78 ] 79 }" 80 81 install -m755 findoid "$out/bin/findoid" 82 wrapProgram "$out/bin/findoid" \ 83 --prefix PERL5LIB : "$PERL5LIB" \ 84 --prefix PATH : "${ 85 lib.makeBinPath [ 86 "/run/booted-system/sw" 87 zfs 88 ] 89 }" 90 91 runHook postInstall 92 ''; 93 94 meta = with lib; { 95 description = "Policy-driven snapshot management tool for ZFS filesystems"; 96 homepage = "https://github.com/jimsalterjrs/sanoid"; 97 license = licenses.gpl3Plus; 98 maintainers = with maintainers; [ 99 lopsided98 100 Frostman 101 ]; 102 platforms = platforms.all; 103 }; 104}