Move all nixos-modules out of qois subfolder
This commit is contained in:
parent
d49f58265f
commit
97d1a30329
22 changed files with 3 additions and 14 deletions
53
nixos-modules/backup-server/default.nix
Normal file
53
nixos-modules/backup-server/default.nix
Normal file
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
options,
|
||||
pkgs,
|
||||
self,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.qois.backup-server or { };
|
||||
in
|
||||
with lib;
|
||||
{
|
||||
options.qois.backup-server = {
|
||||
enable = mkEnableOption "Enable backup hosting";
|
||||
|
||||
backupStorageRoot = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = "/mnt/backup";
|
||||
example = "/mnt/nas/backup";
|
||||
description = "Path where backups are stored if this host is used as a backup target.";
|
||||
};
|
||||
|
||||
hosts = options.qois.meta.hosts // {
|
||||
default = config.qois.meta.hosts;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.borgbackup.repos =
|
||||
let
|
||||
hasSshKey = hostName: cfg.hosts.${hostName}.sshKey != null;
|
||||
mkRepo =
|
||||
hostName:
|
||||
(
|
||||
let
|
||||
name = "system-${hostName}";
|
||||
in
|
||||
{
|
||||
inherit name;
|
||||
value = {
|
||||
path = "${cfg.backupStorageRoot}/${name}";
|
||||
authorizedKeys = [ cfg.hosts.${hostName}.sshKey ];
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
hostsWithSshKeys = lib.filter hasSshKey (lib.attrNames cfg.hosts);
|
||||
in
|
||||
lib.listToAttrs (map mkRepo hostsWithSshKeys);
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue