Compare commits

...
2 Commits
Author SHA1 Message Date
oqyude 7cbdd5860b proxy-suite added 2026-07-04 23:33:33 +03:00
oqyude f2740e87a0 node backup added 2026-07-04 22:54:38 +03:00
6 changed files with 128 additions and 2 deletions
Generated
+21
View File
@@ -260,6 +260,26 @@
"type": "github"
}
},
"proxy-suite": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1783174389,
"narHash": "sha256-aCWC8ngycU7OdJrU2+Je3qf+1a2ykuBvpPhZT/9tXMc=",
"owner": "Mic92",
"repo": "sops-nix",
"rev": "f1406619a3884cd5c47992a70b8b35c9c0fcb4c9",
"type": "github"
},
"original": {
"owner": "Mic92",
"repo": "sops-nix",
"type": "github"
}
},
"root": {
"inputs": {
"deploy-rs": "deploy-rs",
@@ -275,6 +295,7 @@
"nixpkgs-master": "nixpkgs-master",
"nixpkgs-stable": "nixpkgs-stable",
"plasma-manager": "plasma-manager",
"proxy-suite": "proxy-suite",
"sops-nix": "sops-nix",
"utils": "utils",
"zapret": "zapret",
+4
View File
@@ -57,6 +57,10 @@
home-manager.follows = "home-manager";
};
};
proxy-suite = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
+2 -1
View File
@@ -98,11 +98,12 @@
# Folders
tmpfiles.rules = [
"d /mnt 0755 root root -"
"d /mnt/containers 0755 root root -"
"d /mnt/services 0755 root root -"
"d /mnt/services/containers 0755 root root -"
"d /mnt/services/containers/3x-ui 0755 root root -"
"d /mnt/services/containers/3x-ui/cert 0755 root root -"
"d /mnt/services/containers/3x-ui/db 0755 root root -"
"Z /mnt/services/containers/3x-ui 0755 root root -"
];
};
+1 -1
View File
@@ -92,7 +92,7 @@
ssh_key_public_root = {
format = "yaml";
key = "ssh_key_public";
path = "/root/.ssh/id_ed25519";
path = "/root/.ssh/id_ed25519.pub";
owner = "root";
group = "root";
mode = "0655";
+6
View File
@@ -7,8 +7,14 @@
../containers/3x-ui.nix
./nginx.nix
./samba.nix
./systemd.nix
# ./glances.nix
# ./netbird.nix
# ./xray.nix
];
systemd.tmpfiles.rules = [
"d /mnt 0755 root root -"
"d /mnt/services 0755 root root -"
"d /mnt/services/containers 0755 root root -"
];
}
+94
View File
@@ -0,0 +1,94 @@
{
config,
lib,
pkgs,
xlib,
...
}:
let
serviceName = "rsync-services-sync";
serverAddress = "oqyude@100.64.0.0";
serverDir = "/mnt/services/nodes/vds";
nodeDir = "/mnt/services";
in
{
systemd = {
services = {
"${serviceName}" = {
description = "Bidirectional rsync";
unitConfig.RequiresMountsFor = [ ];
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
script = ''
set -euo pipefail
RSYNC="${pkgs.rsync}/bin/rsync"
SSH="${pkgs.openssh}/bin/ssh"
SSH_CMD="$SSH \
-o BatchMode=yes \
-o ConnectTimeout=5 \
-o StrictHostKeyChecking=no"
echo "Waiting for server..."
for i in $(seq 1 60); do
echo "Attempt $i"
if $SSH_CMD ${serverAddress} true >/dev/null 2>&1; then
echo "Server available"
break
fi
sleep 5
done
# final check
$SSH_CMD ${serverAddress} true >/dev/null 2>&1
mkdir -p "${nodeDir}"
if [ ! -d "${nodeDir}" ] || [ -z "$(ls -A "${nodeDir}")" ]; then
echo "Pull <- ${serverAddress}"
mkdir -p "${nodeDir}"
$RSYNC \
-e "$SSH_CMD" \
-a \
"${serverAddress}:${serverDir}/" \
"${nodeDir}/"
else
echo "Push -> ${serverAddress}"
$RSYNC \
-e "$SSH_CMD" \
-a \
--delete \
"${nodeDir}/" \
"${serverAddress}:${serverDir}/"
fi
'';
serviceConfig = {
Type = "oneshot";
User = "root";
Group = "root";
Nice = 10;
CPUQuota = "5%";
IOSchedulingClass = "idle";
};
};
};
timers = {
"${serviceName}" = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "daily";
Persistent = true;
Unit = "${serviceName}.service";
};
};
};
};
}