general: modularize borg/rsync config

This commit is contained in:
Fabian Montero 2025-08-28 14:41:54 -06:00
parent db0040dcf4
commit a739323b41
Signed by: fabian
GPG key ID: 1FFAC35E1798174F
6 changed files with 84 additions and 99 deletions

63
sys/modules/borgsync.nix Normal file
View file

@ -0,0 +1,63 @@
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.local.sys.borgsync;
in {
options.local.sys.borgsync = {
enable = mkEnableOption "borg backup to an rsync.net repo";
paths = mkOption {
type = with types; nullOr (coercedTo str singleton (listOf str));
default = null;
description = "Paths to back up.";
};
exclude = mkOption {
type = with types; listOf str;
description = "Exclude paths.";
default = [];
};
repoName = mkOption {
type = types.str;
description = "Remote rsync repository to back up to.";
};
};
config = mkIf cfg.enable {
services.borgbackup.jobs.rsync = {
paths = cfg.paths;
exclude = cfg.exclude;
user = "root";
group = "root";
doInit = true;
startAt = [
"hourly"
];
inhibitsSleep = true;
persistentTimer = true;
repo = "zh5777@zh5777.rsync.net:${cfg.repoName}";
encryption = {
mode = "repokey-blake2";
passCommand = "cat /var/trust/borg/${cfg.repoName}_passphrase";
};
compression = "auto,lz4";
prune = {
keep = {
hourly = 24;
daily = 7;
weekly = 4;
monthly = 12;
yearly = 99;
};
};
extraArgs = [
"--remote-path=borg14"
];
};
environment.sessionVariables.BORG_REMOTE_PATH = "borg14";
};
}

View file

@ -16,6 +16,7 @@
./net.nix
./steam.nix
./gtklock.nix
./borgsync.nix
];
fonts.packages = with pkgs; [

View file

@ -1,49 +0,0 @@
{
config,
pkgs,
lib,
flakes,
...
}: {
services.borgbackup.jobs = {
rsync = {
paths = [
"/home/fabian/nix"
"/home/fabian/safe"
"/extern/var/media"
"/extern/var/fsociety_backup"
];
exclude = [
];
user = "root";
group = "root";
doInit = true;
startAt = [
"hourly"
];
inhibitsSleep = true;
persistentTimer = true;
repo = "zh5777@zh5777.rsync.net:posixlycorrect";
encryption = {
mode = "repokey-blake2";
passCommand = "cat /var/trust/borg/posixlycorrect_passphrase";
};
compression = "auto,lz4";
prune = {
keep = {
hourly = 24;
daily = 7;
weekly = 4;
monthly = 12;
yearly = 99;
};
};
extraArgs = [
"--remote-path=borg14"
];
};
};
environment.sessionVariables.BORG_REMOTE_PATH = "borg14";
}

View file

@ -9,7 +9,6 @@
flakes.home-manager.nixosModules.home-manager
flakes.impermanence.nixosModule
./hardware-configuration.nix
./borg.nix
];
local.sys = {
@ -22,6 +21,16 @@
androidSupport.enable = true;
steam.enable = true;
gtklock.enable = true;
borgsync = {
enable = true;
paths = [
"/home/fabian/nix"
"/home/fabian/safe"
"/extern/var/media"
"/extern/var/fsociety_backup"
];
repoName = "posixlycorrect";
};
users = {
fabian = {

View file

@ -1,48 +0,0 @@
{
config,
pkgs,
lib,
flakes,
...
}: {
services.borgbackup.jobs = {
rsync = {
paths = [
"/var/lib/forgejo"
"/var/lib/mealie"
"/var/lib/trilium"
];
exclude = [
];
user = "root";
group = "root";
doInit = true;
startAt = [
"hourly"
];
inhibitsSleep = true;
persistentTimer = true;
repo = "zh5777@zh5777.rsync.net:vps";
encryption = {
mode = "repokey-blake2";
passCommand = "cat /var/trust/borg/vps_passphrase";
};
compression = "auto,lz4";
prune = {
keep = {
hourly = 24;
daily = 7;
weekly = 4;
monthly = 12;
yearly = 99;
};
};
extraArgs = [
"--remote-path=borg14"
];
};
};
environment.sessionVariables.BORG_REMOTE_PATH = "borg14";
}

View file

@ -15,11 +15,20 @@ with lib; {
./hardware-configuration.nix
./srv
./networkMap.nix
./borg.nix
];
local.sys = {
baseline.enable = true;
borgsync = {
enable = true;
paths = [
"/var/lib/forgejo"
"/var/lib/mealie"
"/var/lib/trilium"
];
repoName = "vps";
};
users.fabian = {
enable = true;