1
0
Fork 0

add missing user and group to restic instances

This commit is contained in:
ibizaman 2024-08-21 06:13:52 +02:00
parent 0fa4a42be7
commit a48b618923
4 changed files with 36 additions and 4 deletions

View file

@ -1,4 +1,4 @@
{ config, options, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
cfg = config.shb.monitoring; cfg = config.shb.monitoring;

View file

@ -13,6 +13,28 @@ let
type = lib.types.path; type = lib.types.path;
}; };
user = lib.mkOption {
description = ''
Unix user doing the backups.
For Restic, the same user must be used for all instances.
'';
type = lib.types.str;
readOnly = true;
default = cfg.user;
};
group = lib.mkOption {
description = ''
Unix group doing the backups.
For Restic, the same group must be used for all instances.
'';
type = lib.types.str;
readOnly = true;
default = cfg.group;
};
sourceDirectories = lib.mkOption { sourceDirectories = lib.mkOption {
description = "Source directories."; description = "Source directories.";
type = lib.types.nonEmptyListOf lib.types.str; type = lib.types.nonEmptyListOf lib.types.str;
@ -154,6 +176,17 @@ in
enabledInstances = lib.attrsets.filterAttrs (k: i: i.enable) cfg.instances; enabledInstances = lib.attrsets.filterAttrs (k: i: i.enable) cfg.instances;
in lib.mkMerge [ in lib.mkMerge [
{ {
assertions = [
{
assertion = lib.all (x: x.user == cfg.user) (lib.mapAttrsToList (n: v: v)cfg.instances);
message = "All Restic instances must have the same user as 'shb.restic.user'.";
}
{
assertion = lib.all (x: x.group == cfg.group) (lib.mapAttrsToList (n: v: v) cfg.instances);
message = "All Restic instances must have the same group as 'shb.restic.group'.";
}
];
users.users = { users.users = {
${cfg.user} = { ${cfg.user} = {
name = cfg.user; name = cfg.user;

View file

@ -1,4 +1,4 @@
{ config, options, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
cfg = config.shb.arr; cfg = config.shb.arr;

View file

@ -1,8 +1,7 @@
{ config, options, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
cfg = config.shb.nextcloud; cfg = config.shb.nextcloud;
opt = options.shb.nextcloud;
fqdn = "${cfg.subdomain}.${cfg.domain}"; fqdn = "${cfg.subdomain}.${cfg.domain}";
fqdnWithPort = if isNull cfg.port then fqdn else "${fqdn}:${toString cfg.port}"; fqdnWithPort = if isNull cfg.port then fqdn else "${fqdn}:${toString cfg.port}";