Add sops
All checks were successful
pre-commit / pre-commit (push) Successful in 2m2s

This commit is contained in:
2024-03-06 20:17:04 +01:00
parent fd6d93d0cf
commit a7250e9581
10 changed files with 158 additions and 9 deletions

View File

@@ -1,10 +1,17 @@
{ pkgs, ... }:
{ pkgs, config, ... }:
let
# Backup home script
backup-home = pkgs.writeShellScriptBin "backup-home.sh"
''
export RESTIC_PASSWORD="gunter.home.2rjus.net"
export RESTIC_REPOSITORY="rest:http://10.69.12.52:8000/gunter.home.2rjus.net"
GOTIFY_TOKEN=$(<"$XDG_RUNTIME_DIR/gotify_backup_home.txt")
if [ -z "$GOTIFY_TOKEN" ]; then
${pkgs.libnotify}/bin/notify-send -u critical "Backup issue" "No Gotify token found"
fi
echo "GOTIFY_TOKEN=$GOTIFY_TOKEN"
# Send start notification
${pkgs.libnotify}/bin/notify-send -e -t 3000 "Backup started" "Backup of /home/torjus started"
@@ -26,7 +33,7 @@ let
retval=$?
if [ $retval -ne 0 ]; then
# TODO: put token in sops
${pkgs.curl}/bin/curl "https://gotify.t-juice.club/message?token=ABgV8XT62bxyCzF" \
${pkgs.curl}/bin/curl "https://gotify.t-juice.club/message?token=$GOTIFY_TOKEN" \
-F "title=Backup of home@gunter failed!" \
-F "message=Please check status of backup-home service"
fi
@@ -59,10 +66,12 @@ let
'';
in
{
sops.secrets."gotify_backup_home" = { };
systemd.user.services.backup-home = {
Unit = {
Description = "Backup home directory";
After = [ "network.target" ];
After = [ "network.target" "sops-nix.service" ];
};
Service = {
Type = "oneshot";