mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-22 18:29:39 +01:00
borgmatic: optionally exclude HM symlinks from backup
Co-authored-by: Naïm Favier <n@monade.li> Co-authored-by: Robert Helgesson <robert@rycee.net>
This commit is contained in:
parent
2ddd4e151d
commit
a8f5ca239f
5 changed files with 171 additions and 3 deletions
|
|
@ -43,7 +43,10 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
configModule = types.submodule {
|
||||
configModule = types.submodule ({ config, ... }: {
|
||||
config.location.extraConfig.exclude_from =
|
||||
mkIf config.location.excludeHomeManagerSymlinks
|
||||
(mkAfter [ (toString hmExcludeFile) ]);
|
||||
options = {
|
||||
location = {
|
||||
sourceDirectories = mkOption {
|
||||
|
|
@ -59,6 +62,18 @@ let
|
|||
literalExpression ''["ssh://myuser@myrepo.myserver.com/./repo"]'';
|
||||
};
|
||||
|
||||
excludeHomeManagerSymlinks = mkOption {
|
||||
type = types.bool;
|
||||
description = ''
|
||||
Whether to exclude Home Manager generated symbolic links from
|
||||
the backups. This facilitates restoring the whole home
|
||||
directory when the Nix store doesn't contain the latest
|
||||
Home Manager generation.
|
||||
'';
|
||||
default = false;
|
||||
example = true;
|
||||
};
|
||||
|
||||
extraConfig = extraConfigOption;
|
||||
};
|
||||
|
||||
|
|
@ -120,10 +135,18 @@ let
|
|||
extraConfig = extraConfigOption;
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
removeNullValues = attrSet: filterAttrs (key: value: value != null) attrSet;
|
||||
|
||||
hmFiles = builtins.attrValues config.home.file;
|
||||
hmSymlinks = (lib.filter (file: !file.recursive) hmFiles);
|
||||
hmExcludePattern = file: ''
|
||||
${config.home.homeDirectory}/${file.target}
|
||||
'';
|
||||
hmExcludePatterns = lib.concatMapStrings hmExcludePattern hmSymlinks;
|
||||
hmExcludeFile = pkgs.writeText "hm-symlinks.txt" hmExcludePatterns;
|
||||
|
||||
writeConfig = config:
|
||||
generators.toYAML { } {
|
||||
location = removeNullValues {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue