Last active
March 20, 2023 18:48
-
-
Save DamienCassou/8b35027f35ad8f81b9657cf78d55c859 to your computer and use it in GitHub Desktop.
borgmatic.nix patch to simplify merge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From ae12a245b8800e5896657f868e2eebac0449ca26 Mon Sep 17 00:00:00 2001 | |
From: Damien Cassou <damien@cassou.me> | |
Date: Mon, 20 Mar 2023 19:43:49 +0100 | |
Subject: [PATCH] WIP | |
--- | |
modules/programs/borgmatic.nix | 20 +++++++++----------- | |
1 file changed, 9 insertions(+), 11 deletions(-) | |
diff --git a/modules/programs/borgmatic.nix b/modules/programs/borgmatic.nix | |
index 7ad82b90..b07bf943 100644 | |
--- a/modules/programs/borgmatic.nix | |
+++ b/modules/programs/borgmatic.nix | |
@@ -5,6 +5,8 @@ with lib; | |
let | |
cfg = config.programs.borgmatic; | |
+ yamlFormat = pkgs.formats.yaml { }; | |
+ | |
mkNullableOption = args: | |
lib.mkOption (args // { | |
type = lib.types.nullOr args.type; | |
@@ -20,7 +22,7 @@ let | |
}; | |
extraConfigOption = mkOption { | |
- type = with types; attrsOf (oneOf [ str bool path int (listOf str) ]); | |
+ type = yamlFormat.type; | |
default = { }; | |
description = "Extra settings."; | |
}; | |
@@ -41,7 +43,10 @@ let | |
}; | |
}; | |
- configModule = types.submodule { | |
+ configModule = types.submodule ({ config, ... }: { | |
+ config.location.extraConfig.exclude_from = | |
+ mkIf config.location.excludeHomeManagerSymlinks | |
+ [ (toString hmExcludeFile) ]; | |
options = { | |
location = { | |
sourceDirectories = mkOption { | |
@@ -130,7 +135,7 @@ let | |
extraConfig = extraConfigOption; | |
}; | |
}; | |
- }; | |
+ }); | |
removeNullValues = attrSet: filterAttrs (key: value: value != null) attrSet; | |
@@ -141,20 +146,13 @@ let | |
''; | |
hmExcludePatterns = lib.concatMapStrings hmExcludePattern hmSymlinks; | |
hmExcludeFile = pkgs.writeText "hm-symlinks.txt" hmExcludePatterns; | |
- hmSymlinksExclusions = config: | |
- lib.optionalAttrs config.location.excludeHomeManagerSymlinks { | |
- exclude_from = | |
- (lib.optionals (config.location.extraConfig ? "exclude_from") | |
- config.location.extraConfig.exclude_from) | |
- ++ [ (toString hmExcludeFile) ]; | |
- }; | |
writeConfig = config: | |
generators.toYAML { } { | |
location = removeNullValues { | |
source_directories = config.location.sourceDirectories; | |
repositories = config.location.repositories; | |
- } // config.location.extraConfig // (hmSymlinksExclusions config); | |
+ } // config.location.extraConfig; | |
storage = removeNullValues { | |
encryption_passcommand = config.storage.encryptionPasscommand; | |
} // config.storage.extraConfig; | |
-- | |
2.38.4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment