mirror of
https://github.com/phfroidmont/self-hosting.git
synced 2025-12-25 13:46:59 +01:00
Start migrating config to NixOS modules
This commit is contained in:
parent
c1211cb4e5
commit
c0d929be0b
11 changed files with 283 additions and 183 deletions
|
|
@ -1,68 +0,0 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.services.custom-backup-job;
|
||||
in
|
||||
{
|
||||
options.services.custom-backup-job = {
|
||||
additionalPaths = mkOption {
|
||||
type = with types; listOf path;
|
||||
default = [ ];
|
||||
};
|
||||
|
||||
readWritePaths = mkOption {
|
||||
type = with types; listOf path;
|
||||
default = [ ];
|
||||
};
|
||||
|
||||
preHook = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
};
|
||||
|
||||
postHook = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
};
|
||||
|
||||
startAt = mkOption {
|
||||
type = with types; either str (listOf str);
|
||||
default = "03:30";
|
||||
};
|
||||
|
||||
sshKey = mkOption {
|
||||
type = with types; path;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
|
||||
sops.secrets = {
|
||||
borgPassphrase = {
|
||||
owner = config.services.borgbackup.jobs.data.user;
|
||||
key = "borg/passphrase";
|
||||
};
|
||||
};
|
||||
services.borgbackup.jobs.data = {
|
||||
paths = [ "/nix/var/data" cfg.sshKey ] ++ cfg.additionalPaths;
|
||||
doInit = false;
|
||||
repo = "backup@212.129.12.205:./";
|
||||
encryption = {
|
||||
mode = "repokey-blake2";
|
||||
passCommand = "cat ${config.sops.secrets.borgPassphrase.path}";
|
||||
};
|
||||
readWritePaths = cfg.readWritePaths;
|
||||
preHook = cfg.preHook;
|
||||
postHook = cfg.postHook;
|
||||
environment = { BORG_RSH = "ssh -i ${cfg.sshKey}"; };
|
||||
compression = "lz4";
|
||||
startAt = cfg.startAt;
|
||||
prune.keep = {
|
||||
within = "2d";
|
||||
daily = 14;
|
||||
weekly = 8;
|
||||
monthly = 12;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue