From 93f2c180d016c2e450722de58b904567de9f649f Mon Sep 17 00:00:00 2001 From: Aristid Breitkreuz Date: Mon, 27 Oct 2014 20:38:19 +0100 Subject: [PATCH] rsnapshot: add git version & make it configurable in the nixos module --- nixos/modules/services/backup/rsnapshot.nix | 11 +++++- pkgs/tools/backup/rsnapshot/git.nix | 41 +++++++++++++++++++++ pkgs/top-level/all-packages.nix | 5 +++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 pkgs/tools/backup/rsnapshot/git.nix diff --git a/nixos/modules/services/backup/rsnapshot.nix b/nixos/modules/services/backup/rsnapshot.nix index 091b5cfd4d59..fb25bd9dd1e8 100644 --- a/nixos/modules/services/backup/rsnapshot.nix +++ b/nixos/modules/services/backup/rsnapshot.nix @@ -39,11 +39,20 @@ in as retain options. ''; }; + + package = mkOption { + type = types.package; + default = pkgs.rsnapshot; + example = literalExample "pkgs.rsnapshotGit"; + description = '' + RSnapshot package to use. + ''; + }; }; }; config = mkIf cfg.enable (let - myRsnapshot = pkgs.rsnapshot.override { configFile = rsnapshotCfg; }; + myRsnapshot = cfg.package.override { configFile = rsnapshotCfg; }; rsnapshotCfg = with pkgs; writeText "gen-rsnapshot.conf" ('' config_version 1.2 cmd_cp ${coreutils}/bin/cp diff --git a/pkgs/tools/backup/rsnapshot/git.nix b/pkgs/tools/backup/rsnapshot/git.nix new file mode 100644 index 000000000000..79bae0a26613 --- /dev/null +++ b/pkgs/tools/backup/rsnapshot/git.nix @@ -0,0 +1,41 @@ +{ fetchFromGitHub, stdenv, writeText, perl, openssh, rsync, logger, + configFile ? "/etc/rsnapshot.conf" }: + +let patch = writeText "rsnapshot-config.patch" '' +--- rsnapshot-program.pl 2013-10-05 20:31:08.715991442 +0200 ++++ rsnapshot-program.pl 2013-10-05 20:31:42.496193633 +0200 +@@ -383,7 +383,7 @@ + } + + # set global variable +- $config_file = $default_config_file; ++ $config_file = '${configFile}'; + } + + # accepts no args +''; +in +stdenv.mkDerivation rec { + name = "rsnapshot-1.4git"; + src = fetchFromGitHub { + owner = "DrHyde"; + repo = "rsnapshot"; + rev = "1047cbb57937c29233388e2fcd847fecd3babe74"; + sha256 = "173y9q89dp4zf7nysqhjp3i2m086n7qdpawb9vx0ml5zha6mxf2p"; + }; + + propagatedBuildInputs = [perl openssh rsync logger]; + + patchPhase = '' + substituteInPlace "Makefile.in" --replace \ + "/usr/bin/pod2man" "${perl}/bin/pod2man" + patch -p0 <${patch} + ''; + + meta = with stdenv.lib; { + description = "A filesystem snapshot utility for making backups of local and remote systems"; + homepage = http://rsnapshot.org/; + license = stdenv.lib.licenses.gpl2Plus; + platforms = platforms.linux; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4343f147a479..f1868865af22 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2179,6 +2179,11 @@ let # GNU Inetutils. The latter is more portable. logger = inetutils; }; + rsnapshotGit = lowPrio (callPackage ../tools/backup/rsnapshot/git.nix { + # For the `logger' command, we can use either `utillinux' or + # GNU Inetutils. The latter is more portable. + logger = inetutils; + }); rlwrap = callPackage ../tools/misc/rlwrap { };