mirror of
https://github.com/nix-community/home-manager
synced 2024-12-26 03:39:47 +01:00
borgmatic: preparing upcoming borgmatic change
This commit changes the config format of repositories to the soon-be-expected `{ "path": "repository-path", }`. The Home Manager configuration allows a simple string (which will get translated), the new format by directly using the path attribute, and the one with the optional label attribute. More information about the background can be found here https://torsion.org/borgmatic/docs/reference/configuration/
This commit is contained in:
parent
990fc60aaf
commit
0d9be30cfb
2 changed files with 62 additions and 9 deletions
|
@ -13,6 +13,13 @@ let
|
||||||
default = null;
|
default = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
cleanRepositories = repos:
|
||||||
|
map (repo:
|
||||||
|
if builtins.isString repo then {
|
||||||
|
path = repo;
|
||||||
|
} else
|
||||||
|
removeNullValues repo) repos;
|
||||||
|
|
||||||
mkRetentionOption = frequency:
|
mkRetentionOption = frequency:
|
||||||
mkNullableOption {
|
mkNullableOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
|
@ -27,6 +34,26 @@ let
|
||||||
description = "Extra settings.";
|
description = "Extra settings.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
repositoryOption = types.submodule {
|
||||||
|
options = {
|
||||||
|
path = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
example = "ssh://myuser@myrepo.myserver.com/./repo";
|
||||||
|
description = "Path of the repository.";
|
||||||
|
};
|
||||||
|
|
||||||
|
label = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
example = "remote";
|
||||||
|
description = ''
|
||||||
|
Short text describing the repository. Can be used with the
|
||||||
|
`--repository` flag to select a repository.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
consistencyCheckModule = types.submodule {
|
consistencyCheckModule = types.submodule {
|
||||||
options = {
|
options = {
|
||||||
name = mkOption {
|
name = mkOption {
|
||||||
|
@ -56,10 +83,23 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
repositories = mkOption {
|
repositories = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf (types.either types.str repositoryOption);
|
||||||
description = "Paths to repositories.";
|
apply = cleanRepositories;
|
||||||
example =
|
example = literalExpression ''
|
||||||
literalExpression ''["ssh://myuser@myrepo.myserver.com/./repo"]'';
|
[
|
||||||
|
{
|
||||||
|
"path" = "ssh://myuser@myrepo.myserver.com/./repo";
|
||||||
|
"label" = "server";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"path" = "/var/lib/backups/local.borg";
|
||||||
|
"label" = "local";
|
||||||
|
}
|
||||||
|
]
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
List of local or remote repositories with paths and optional labels.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
excludeHomeManagerSymlinks = mkOption {
|
excludeHomeManagerSymlinks = mkOption {
|
||||||
|
|
|
@ -12,7 +12,14 @@ in {
|
||||||
main = {
|
main = {
|
||||||
location = {
|
location = {
|
||||||
sourceDirectories = [ "/my-stuff-to-backup" ];
|
sourceDirectories = [ "/my-stuff-to-backup" ];
|
||||||
repositories = [ "/mnt/disk1" "/mnt/disk2" ];
|
repositories = [
|
||||||
|
"/mnt/disk1"
|
||||||
|
{ path = "/mnt/disk2"; }
|
||||||
|
{
|
||||||
|
path = "/mnt/disk3";
|
||||||
|
label = "disk3";
|
||||||
|
}
|
||||||
|
];
|
||||||
extraConfig = {
|
extraConfig = {
|
||||||
one_file_system = true;
|
one_file_system = true;
|
||||||
exclude_patterns = [ "*.swp" ];
|
exclude_patterns = [ "*.swp" ];
|
||||||
|
@ -65,11 +72,17 @@ in {
|
||||||
expectations[source_directories[0]]="${
|
expectations[source_directories[0]]="${
|
||||||
builtins.elemAt backups.main.location.sourceDirectories 0
|
builtins.elemAt backups.main.location.sourceDirectories 0
|
||||||
}"
|
}"
|
||||||
expectations[repositories[0]]="${
|
expectations[repositories[0].path]="${
|
||||||
builtins.elemAt backups.main.location.repositories 0
|
(builtins.elemAt backups.main.location.repositories 0).path
|
||||||
}"
|
}"
|
||||||
expectations[repositories[1]]="${
|
expectations[repositories[1].path]="${
|
||||||
builtins.elemAt backups.main.location.repositories 1
|
(builtins.elemAt backups.main.location.repositories 1).path
|
||||||
|
}"
|
||||||
|
expectations[repositories[2].path]="${
|
||||||
|
(builtins.elemAt backups.main.location.repositories 2).path
|
||||||
|
}"
|
||||||
|
expectations[repositories[2].label]="${
|
||||||
|
(builtins.elemAt backups.main.location.repositories 2).label
|
||||||
}"
|
}"
|
||||||
expectations[one_file_system]="${
|
expectations[one_file_system]="${
|
||||||
boolToString backups.main.location.extraConfig.one_file_system
|
boolToString backups.main.location.extraConfig.one_file_system
|
||||||
|
|
Loading…
Reference in a new issue