1{ lib
2, stdenv
3, borgbackup
4, coreutils
5, python3Packages
6, fetchPypi
7, systemd
8, enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
9, installShellFiles
10, borgmatic
11, testers
12}:
13
14python3Packages.buildPythonApplication rec {
15 pname = "borgmatic";
16 version = "1.8.1";
17
18 src = fetchPypi {
19 inherit pname version;
20 sha256 = "sha256-XbihTQJtoiRRfwjMCP+XEPmbt7//zFPx1fIWOvn92Nc=";
21 };
22
23 nativeCheckInputs = with python3Packages; [ flexmock pytestCheckHook pytest-cov ];
24
25 # - test_borgmatic_version_matches_news_version
26 # The file NEWS not available on the pypi source, and this test is useless
27 disabledTests = [
28 "test_borgmatic_version_matches_news_version"
29 ];
30
31 nativeBuildInputs = [ installShellFiles ];
32
33 propagatedBuildInputs = with python3Packages; [
34 borgbackup
35 colorama
36 jsonschema
37 packaging
38 ruamel-yaml
39 requests
40 setuptools
41 ];
42
43 postInstall = ''
44 installShellCompletion --cmd borgmatic \
45 --bash <($out/bin/borgmatic --bash-completion)
46 '' + lib.optionalString enableSystemd ''
47 mkdir -p $out/lib/systemd/system
48 cp sample/systemd/borgmatic.timer $out/lib/systemd/system/
49 # there is another "sleep", so choose the one with the space after it
50 # due to https://github.com/borgmatic-collective/borgmatic/commit/2e9f70d49647d47fb4ca05f428c592b0e4319544
51 substitute sample/systemd/borgmatic.service \
52 $out/lib/systemd/system/borgmatic.service \
53 --replace /root/.local/bin/borgmatic $out/bin/borgmatic \
54 --replace systemd-inhibit ${systemd}/bin/systemd-inhibit \
55 --replace "sleep " "${coreutils}/bin/sleep "
56 '';
57
58 passthru.tests.version = testers.testVersion { package = borgmatic; };
59
60 __darwinAllowLocalNetworking = true;
61
62 meta = with lib; {
63 description = "Simple, configuration-driven backup software for servers and workstations";
64 homepage = "https://torsion.org/borgmatic/";
65 license = licenses.gpl3Plus;
66 platforms = platforms.all;
67 maintainers = with maintainers; [ imlonghao ];
68 };
69}