Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib 2, stdenv 3, fetchurl 4, bash 5, btrfs-progs 6, openssh 7, perl 8, perlPackages 9, util-linux 10, asciidoctor 11, mbuffer 12, makeWrapper 13, genericUpdater 14, curl 15, writeShellScript 16, nixosTests 17}: 18 19stdenv.mkDerivation rec { 20 pname = "btrbk"; 21 version = "0.32.6"; 22 23 src = fetchurl { 24 url = "https://digint.ch/download/btrbk/releases/${pname}-${version}.tar.xz"; 25 sha256 = "AuKsZHyRhGMgLL5ge7lVV6T3/SNwaRJDM8VNpbK7t2s="; 26 }; 27 28 nativeBuildInputs = [ asciidoctor makeWrapper ]; 29 30 buildInputs = with perlPackages; [ perl DateCalc ]; 31 32 preInstall = '' 33 for f in $(find . -name Makefile); do 34 substituteInPlace "$f" \ 35 --replace "/usr" "$out" \ 36 --replace "/etc" "$out/etc" 37 done 38 39 # Tainted Mode disables PERL5LIB 40 substituteInPlace btrbk \ 41 --replace "perl -T" "perl" \ 42 --replace "\$0" "\$ENV{'program_name'}" 43 44 # Fix SSH filter script 45 sed -i '/^export PATH/d' ssh_filter_btrbk.sh 46 substituteInPlace ssh_filter_btrbk.sh --replace logger ${util-linux}/bin/logger 47 ''; 48 49 preFixup = '' 50 wrapProgram $out/bin/btrbk \ 51 --set PERL5LIB $PERL5LIB \ 52 --run 'export program_name=$0' \ 53 --prefix PATH ':' "${lib.makeBinPath [ btrfs-progs bash mbuffer openssh ]}" 54 ''; 55 56 passthru.tests = { 57 inherit (nixosTests) btrbk btrbk-no-timer btrbk-section-order btrbk-doas; 58 }; 59 60 passthru.updateScript = genericUpdater { 61 versionLister = writeShellScript "btrbk-versionLister" '' 62 ${curl}/bin/curl -s https://digint.ch/download/btrbk/releases/ | ${perl}/bin/perl -lne 'print $1 if /btrbk-([0-9.]*)\.tar/' 63 ''; 64 }; 65 66 meta = with lib; { 67 description = "A backup tool for btrfs subvolumes"; 68 homepage = "https://digint.ch/btrbk"; 69 license = licenses.gpl3Only; 70 platforms = platforms.unix; 71 maintainers = with maintainers; [ asymmetric ]; 72 }; 73}