feat: simplified the config for running services, only one hosts config is required now in each server config file
This commit is contained in:
parent
f8c7860eb5
commit
379cb84839
34 changed files with 200 additions and 581 deletions
|
@ -39,21 +39,23 @@ with lib; let
|
|||
lib.attrsets.mapAttrsToList (
|
||||
key: value: let
|
||||
backup = value.config.services.skynet.backup;
|
||||
backup_host = value.config.services.skynet.host;
|
||||
in
|
||||
if
|
||||
(
|
||||
(builtins.hasAttr "backup" value.config.services.skynet)
|
||||
&& backup.server.enable
|
||||
&& backup.host.name != cfg.host.name
|
||||
# chgeck that its not itself
|
||||
&& backup_host.name != config.services.skynet.host.name
|
||||
&& !backup.server.appendOnly
|
||||
)
|
||||
then [
|
||||
{
|
||||
name = backup.host.name;
|
||||
name = backup_host.name;
|
||||
value =
|
||||
base
|
||||
// {
|
||||
repositoryFile = "/etc/skynet/restic/${backup.host.name}";
|
||||
repositoryFile = "/etc/skynet/restic/${backup_host.name}";
|
||||
|
||||
backupPrepareCommand = ''
|
||||
#!${pkgs.stdenv.shell}
|
||||
|
@ -64,13 +66,13 @@ with lib; let
|
|||
mkdir -p $baseDir
|
||||
cd $baseDir
|
||||
|
||||
echo -n "rest:http://root:password@${backup.host.ip}:${toString backup.server.port}/root/${cfg.host.name}" > ${backup.host.name}
|
||||
echo -n "rest:http://root:password@${backup_host.ip}:${toString backup.server.port}/root/${config.services.skynet.host.name}" > ${backup_host.name}
|
||||
|
||||
# read in teh password
|
||||
#PW = `cat ${config.age.secrets.restic.path}`
|
||||
line=$(head -n 1 ${config.age.secrets.restic.path})
|
||||
|
||||
sed -i "s/password/$line/g" ${backup.host.name}
|
||||
sed -i "s/password/$line/g" ${backup_host.name}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
@ -87,8 +89,7 @@ in {
|
|||
# https://git.hrnz.li/Ulli/nixos/src/commit/5edca2dfdab3ce52208e4dfd2b92951e500f8418/profiles/server/restic.nix
|
||||
# will eb enabled on every server
|
||||
options.services.skynet."${name}" = {
|
||||
# backup is enabled by default
|
||||
# enable = mkEnableOption "Skynet backup";
|
||||
enable = mkEnableOption "Skynet backup";
|
||||
|
||||
# what folders to backup
|
||||
normal = {
|
||||
|
@ -128,16 +129,6 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
host = {
|
||||
ip = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
server = {
|
||||
enable = mkEnableOption "Skynet backup Server";
|
||||
|
||||
|
@ -176,7 +167,7 @@ in {
|
|||
|
||||
services.restic.server = {
|
||||
enable = true;
|
||||
listenAddress = "${cfg.host.ip}:${toString cfg.server.port}";
|
||||
listenAddress = "${config.services.skynet.host.ip}:${toString cfg.server.port}";
|
||||
appendOnly = cfg.server.appendOnly;
|
||||
privateRepos = true;
|
||||
};
|
||||
|
@ -196,7 +187,7 @@ in {
|
|||
# merge teh two configs together
|
||||
# backblaze = base // {
|
||||
# # backupos for each server are stored in a folder under their name
|
||||
# repository = "b2:NixOS-Main2:/${cfg.host.name}";
|
||||
# repository = "b2:NixOS-Main2:/${config.services.skynet.host.name}";
|
||||
# #environmentFile = config.age.secrets.backblaze.path;
|
||||
# };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue