Add postgres bins to borgmatic environment
All checks were successful
Check flake / build-amd64-linux (push) Successful in 2m25s

This commit is contained in:
Jordan Holt 2024-07-21 13:35:03 +01:00
parent 296da660c0
commit c25405ccbf
Signed by: jordan
GPG Key ID: B8CFFF61F1CCF520

View File

@ -1,33 +1,31 @@
{ config, lib, pkgs, inputs, ... }: { config, lib, pkgs, inputs, ... }:
with lib;
let let
cfg = config.modules.services.borgmatic; cfg = config.modules.services.borgmatic;
hostname = config.networking.hostName; hostname = config.networking.hostName;
in { in {
options.modules.services.borgmatic = { options.modules.services.borgmatic = {
enable = mkOption { enable = lib.mkOption {
default = false; default = false;
example = true; example = true;
description = mdDoc "Enable backups on this host with `borgmatic`"; description = lib.mdDoc "Enable backups on this host with `borgmatic`";
}; };
directories = mkOption { directories = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
default = []; default = [];
example = [ example = [
"/home/jordan/Documents" "/home/jordan/Documents"
]; ];
description = mdDoc "List of directories to backup"; description = lib.mdDoc "List of directories to backup";
}; };
repoPath = mkOption { repoPath = lib.mkOption {
type = types.str; type = lib.types.str;
example = "ssh://example@example.repo.borgbase.com/./repo"; example = "ssh://example@example.repo.borgbase.com/./repo";
description = mdDoc "Destination borg repository for backup"; description = lib.mdDoc "Destination borg repository for backup";
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
age.secrets."passwords/services/borg/${hostname}-passphrase" = { age.secrets."passwords/services/borg/${hostname}-passphrase" = {
file = "${inputs.secrets}/passwords/services/borg/${hostname}-passphrase.age"; file = "${inputs.secrets}/passwords/services/borg/${hostname}-passphrase.age";
}; };
@ -47,6 +45,9 @@ in {
}; };
}; };
# Add `pg_dumpall` to unit environment
systemd.services.borgmatic.path = [ pkgs.postgresql ];
# Without this override, `cat` is unavailable for `encryption_passcommand` # Without this override, `cat` is unavailable for `encryption_passcommand`
systemd.services.borgmatic.confinement.fullUnit = true; systemd.services.borgmatic.confinement.fullUnit = true;
}; };