mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 23:11:34 +01:00
Run all restic backups as root
This commit is contained in:
parent
f5e59e0d12
commit
2e53bdb015
7 changed files with 11 additions and 43 deletions
|
|
@ -2,7 +2,7 @@
|
|||
let
|
||||
resticBackups = lib.filterAttrs (_: value: value.enable) config.custom.services.resticBackups;
|
||||
|
||||
backupUsers = lib.mapAttrsToList (_: value: value.user) resticBackups;
|
||||
# user = config.users.users.restic.name;
|
||||
in
|
||||
{
|
||||
options.custom.services.resticBackups = lib.mkOption {
|
||||
|
|
@ -12,10 +12,6 @@ in
|
|||
enable = lib.mkEnableOption "" // {
|
||||
default = true;
|
||||
};
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = config.users.users.root.name;
|
||||
};
|
||||
dependentService = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.nonEmptyStr;
|
||||
default = null;
|
||||
|
|
@ -31,19 +27,10 @@ in
|
|||
};
|
||||
|
||||
config = lib.mkIf (resticBackups != { }) {
|
||||
users.groups.backup.members = backupUsers;
|
||||
|
||||
sops.secrets =
|
||||
let
|
||||
resticPermissions = {
|
||||
mode = "440";
|
||||
group = config.users.groups.backup.name;
|
||||
};
|
||||
in
|
||||
{
|
||||
"restic/environment" = resticPermissions;
|
||||
"restic/password" = resticPermissions;
|
||||
};
|
||||
sops.secrets = {
|
||||
"restic/environment" = { };
|
||||
"restic/password" = { };
|
||||
};
|
||||
|
||||
services.restic.backups =
|
||||
resticBackups
|
||||
|
|
@ -51,7 +38,7 @@ in
|
|||
name: value:
|
||||
lib.mkMerge [
|
||||
{
|
||||
inherit (value) user;
|
||||
#inherit user;
|
||||
initialize = true;
|
||||
repository = "s3:https://s3.eu-central-003.backblazeb2.com/stork-atlas/${name}";
|
||||
environmentFile = config.sops.secrets."restic/environment".path;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue