nixpkgs/pkgs/by-name/bo/borgmatic/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

78 lines
2.2 KiB
Nix

{
borgbackup,
borgmatic,
coreutils,
enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd,
fetchPypi,
installShellFiles,
lib,
python3Packages,
stdenv,
systemd,
testers,
nixosTests,
}:
python3Packages.buildPythonApplication rec {
pname = "borgmatic";
version = "1.8.14";
src = fetchPypi {
inherit pname version;
hash = "sha256-WYs7wiwZ1TvTdeUpWv7FbREXWfdGcYRarP4FXFOfp0Y=";
};
nativeCheckInputs = with python3Packages; [ flexmock pytestCheckHook pytest-cov ] ++ optional-dependencies.apprise;
# - test_borgmatic_version_matches_news_version
# The file NEWS not available on the pypi source, and this test is useless
disabledTests = [
"test_borgmatic_version_matches_news_version"
];
nativeBuildInputs = [ installShellFiles ];
propagatedBuildInputs = with python3Packages; [
borgbackup
colorama
jsonschema
packaging
requests
ruamel-yaml
setuptools
];
optional-dependencies = {
apprise = [ python3Packages.apprise ];
};
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 "
'';
passthru.tests = {
version = testers.testVersion { package = borgmatic; };
inherit (nixosTests) borgmatic;
};
__darwinAllowLocalNetworking = true;
meta = {
description = "Simple, configuration-driven backup software for servers and workstations";
homepage = "https://torsion.org/borgmatic/";
license = lib.licenses.gpl3Plus;
platforms = lib.platforms.all;
maintainers = with lib.maintainers; [ imlonghao x123 ];
};
}