Compare commits
3 commits
91d382041c
...
83b4cc0051
Author | SHA1 | Date | |
---|---|---|---|
83b4cc0051 | |||
af12d13e25 | |||
12c66d1be7 |
4 changed files with 28 additions and 19 deletions
|
@ -1,4 +1,4 @@
|
|||
{ lib, ... }: {
|
||||
{ lib, config, pkgs, ... }: {
|
||||
imports = [
|
||||
../../common
|
||||
../../profiles/headless.nix
|
||||
|
@ -13,7 +13,9 @@
|
|||
};
|
||||
kyouma.nginx.defaultForbidden = "florp.social";
|
||||
|
||||
kyouma.restic = {
|
||||
kyouma.restic = let
|
||||
pgBackup = "/var/cache/postgresql.sql";
|
||||
in {
|
||||
enable = true;
|
||||
remoteUser = "zh3485s1";
|
||||
timerConfig = {
|
||||
|
@ -22,9 +24,20 @@
|
|||
};
|
||||
paths = [
|
||||
"/var/lib/akkoma"
|
||||
"/var/lib/postgresql"
|
||||
"/var/lib/secrets"
|
||||
pgBackup
|
||||
];
|
||||
|
||||
backupPrepareCommand = ''
|
||||
umask 0077
|
||||
rm -f -- ${pgBackup}
|
||||
su -c '${lib.getExe' config.services.postgresql.package "pg_dumpall"}' \
|
||||
${config.services.postgresql.superUser} >${pgBackup}
|
||||
'';
|
||||
|
||||
backupCleanupCommand = ''
|
||||
rm -f -- ${pgBackup}
|
||||
'';
|
||||
};
|
||||
systemd.network.networks."98-eth-default" = {
|
||||
address = [
|
||||
|
|
|
@ -437,11 +437,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731185407,
|
||||
"narHash": "sha256-4LdV+ZK7slyONezfW3aZmBuTt4lnxBTmREemBW7VBtk=",
|
||||
"lastModified": 1731187545,
|
||||
"narHash": "sha256-n/BOlXvOcX5yn2mbjazfCcbojzczCdmcjQNaH7Dcdd4=",
|
||||
"ref": "refs/heads/main",
|
||||
"rev": "1d3098ad7775426c092a5bd13498d98a8b02b116",
|
||||
"revCount": 6,
|
||||
"rev": "1845276697adca236be3e7a983238d2a2d0d57b5",
|
||||
"revCount": 7,
|
||||
"type": "git",
|
||||
"url": "https://woof.rip/florp/about.git"
|
||||
},
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
{ config, lib, pkgs, utils, ... }: let
|
||||
{ config, lib, options, pkgs, ... }: let
|
||||
cfg = config.kyouma.restic;
|
||||
in {
|
||||
options.kyouma.restic = let
|
||||
inherit (lib) mkOption types;
|
||||
in {
|
||||
inherit (options.services.restic.backups.type.getSubOptions [])
|
||||
timerConfig backupPrepareCommand backupCleanupCommand;
|
||||
enable = lib.mkEnableOption "Enable restic backup";
|
||||
paths = mkOption {
|
||||
description = "paths to backup";
|
||||
|
@ -40,14 +42,6 @@ in {
|
|||
type = types.nonEmptyStr;
|
||||
default = "${config.networking.hostName}-backup";
|
||||
};
|
||||
timerConfig = mkOption {
|
||||
description = "timer config";
|
||||
type = with types; nullOr (attrsOf utils.systemdUtils.unitOptions.unitOption);
|
||||
default = {
|
||||
OnCalendar = "daily";
|
||||
Persistent = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
sops.secrets."restic/${cfg.remoteUser}/password" = {
|
||||
|
@ -58,7 +52,7 @@ in {
|
|||
};
|
||||
|
||||
services.restic.backups."${config.networking.hostName}-${cfg.remote}" = {
|
||||
inherit (cfg) paths user pruneOpts timerConfig;
|
||||
inherit (cfg) paths user pruneOpts timerConfig backupPrepareCommand backupCleanupCommand;
|
||||
initialize = true;
|
||||
repository = "sftp:${cfg.remoteUser}@${cfg.remote}:${cfg.repo}";
|
||||
passwordFile = config.sops.secrets."restic/${cfg.remoteUser}/password".path;
|
||||
|
|
|
@ -23,6 +23,7 @@ merge_theirs () {
|
|||
test_build () {
|
||||
local last_error
|
||||
local build_jobs
|
||||
local now
|
||||
|
||||
build_jobs="$(curl --fail -s -L -H "Accept: application/json" "${JOBSET_URL}/latest-eval" | jq -r ".builds | .[]")"
|
||||
for build in ${build_jobs}; do
|
||||
|
@ -42,8 +43,9 @@ test_build () {
|
|||
echo "Build ${build} was successful"
|
||||
done
|
||||
|
||||
now="$(date +%s)"
|
||||
last_error="$(curl --fail -s -L -H "Accept: application/json" "${JOBSET_URL}" | jq -r ".errortime")"
|
||||
[[ $last_error -gt $(date +%s) ]] &&
|
||||
[[ $last_error -gt $now ]] &&
|
||||
echo "Evaluation error encountered at $(date +%Y-%m-%d-%H:%M:%S --date="@${last_error}")" &&
|
||||
exit 1
|
||||
}
|
||||
|
@ -55,7 +57,7 @@ wait_for_hydra () {
|
|||
counter=0
|
||||
git_rev="$(git -C "${1}/nixfiles" rev-parse update-inputs)"
|
||||
while true; do
|
||||
hydra_rev="$(curl -s -L -H "Accept: application/json" "${2}/latest-eval" | jq -r .flake | sed -E "s/.+&rev=(.*)/\1/g")"
|
||||
hydra_rev="$(curl -s -L -H "Accept: application/json" "${2}/evals" | jq -r '.evals | max_by(.id) | .flake' | sed -E "s/.+&rev=(.*)/\1/g")"
|
||||
if [[ "${git_rev}" == "${hydra_rev}" ]]; then
|
||||
echo "Hydra got new commit"
|
||||
break
|
||||
|
|
Loading…
Reference in a new issue