about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/backup/borgmatic/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/tools/backup/borgmatic/default.nix')
-rw-r--r--nixpkgs/pkgs/tools/backup/borgmatic/default.nix32
1 files changed, 26 insertions, 6 deletions
diff --git a/nixpkgs/pkgs/tools/backup/borgmatic/default.nix b/nixpkgs/pkgs/tools/backup/borgmatic/default.nix
index a63cdcda7cb8..ea85df188b81 100644
--- a/nixpkgs/pkgs/tools/backup/borgmatic/default.nix
+++ b/nixpkgs/pkgs/tools/backup/borgmatic/default.nix
@@ -1,15 +1,26 @@
-{ borgbackup, coreutils, lib, python3Packages, systemd }:
+{ lib
+, stdenv
+, borgbackup
+, coreutils
+, python3Packages
+, fetchPypi
+, systemd
+, enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
+, installShellFiles
+, borgmatic
+, testers
+}:
 
 python3Packages.buildPythonApplication rec {
   pname = "borgmatic";
-  version = "1.6.4";
+  version = "1.7.9";
 
-  src = python3Packages.fetchPypi {
+  src = fetchPypi {
     inherit pname version;
-    sha256 = "sha256-2kQ+KO69RxpIQkrkD6n7l9ti9ITwdpHYK7LuXYUo3ck=";
+    sha256 = "sha256-v3Qxwy7V6rqX90G4/Xp6mVTUkrqDXmudgh3th0GCjuk=";
   };
 
-  checkInputs = with python3Packages; [ flexmock pytestCheckHook pytest-cov ];
+  nativeCheckInputs = with python3Packages; [ flexmock pytestCheckHook pytest-cov ];
 
   # - test_borgmatic_version_matches_news_version
   # The file NEWS not available on the pypi source, and this test is useless
@@ -17,6 +28,8 @@ python3Packages.buildPythonApplication rec {
     "test_borgmatic_version_matches_news_version"
   ];
 
+  nativeBuildInputs = [ installShellFiles ];
+
   propagatedBuildInputs = with python3Packages; [
     borgbackup
     colorama
@@ -27,15 +40,22 @@ python3Packages.buildPythonApplication rec {
   ];
 
   postInstall = ''
+    installShellCompletion --cmd borgmatic \
+      --bash <($out/bin/borgmatic --bash-completion)
+  '' + lib.optionalString enableSystemd ''
     mkdir -p $out/lib/systemd/system
     cp sample/systemd/borgmatic.timer $out/lib/systemd/system/
+    # there is another "sleep", so choose the one with the space after it
+    # due to https://github.com/borgmatic-collective/borgmatic/commit/2e9f70d49647d47fb4ca05f428c592b0e4319544
     substitute sample/systemd/borgmatic.service \
                $out/lib/systemd/system/borgmatic.service \
                --replace /root/.local/bin/borgmatic $out/bin/borgmatic \
                --replace systemd-inhibit ${systemd}/bin/systemd-inhibit \
-               --replace sleep ${coreutils}/bin/sleep
+               --replace "sleep " "${coreutils}/bin/sleep "
   '';
 
+  passthru.tests.version = testers.testVersion { package = borgmatic; };
+
   meta = with lib; {
     description = "Simple, configuration-driven backup software for servers and workstations";
     homepage = "https://torsion.org/borgmatic/";