From eb7e752f98d01536a5f3f5bac65e5b9c699dc2ac Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 5 Jun 2026 03:25:02 +0000 Subject: [PATCH 1/3] Automated update --- flake.lock | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/flake.lock b/flake.lock index 2bdd327..0a3eb58 100644 --- a/flake.lock +++ b/flake.lock @@ -35,6 +35,22 @@ "type": "github" } }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1780243769, + "narHash": "sha256-x5UQuRsH3MqI0U9afaXSNqzTPSeZlRLvFAav2Ux1pNw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "331800de5053fcebacf6813adb5db9c9dca22a0c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1767313136, @@ -55,6 +71,7 @@ "inputs": { "near-cli": "near-cli", "nixpkgs": "nixpkgs_2", + "nixpkgs-unstable": "nixpkgs-unstable", "systems": "systems_2" } }, From d2311d4549780ba0abcc245712e0530209e8158e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 8 Jun 2026 03:36:24 +0000 Subject: [PATCH 2/3] Automated update --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 0a3eb58..6419bd7 100644 --- a/flake.lock +++ b/flake.lock @@ -37,11 +37,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1780243769, - "narHash": "sha256-x5UQuRsH3MqI0U9afaXSNqzTPSeZlRLvFAav2Ux1pNw=", + "lastModified": 1780749050, + "narHash": "sha256-3av0pIjlOWQ6rDbNOmpUSvbNnJkGORQKKjb4LtCZsIY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "331800de5053fcebacf6813adb5db9c9dca22a0c", + "rev": "a799d3e3886da994fa307f817a6bc705ae538eeb", "type": "github" }, "original": { From a174035581273a7f5766190cebed8b270c333e1d Mon Sep 17 00:00:00 2001 From: Plopmenz Date: Tue, 9 Jun 2026 11:55:18 +0200 Subject: [PATCH 3/3] storage clear --- nixos-module.nix | 56 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/nixos-module.nix b/nixos-module.nix index 8065506..b517868 100644 --- a/nixos-module.nix +++ b/nixos-module.nix @@ -60,6 +60,19 @@ in }; }; }; + + storage-clear = { + enable = lib.mkEnableOption "Enable clearing NEAR validator storage automatically when free storage falls bellow a certain threshold."; + + min-free = lib.mkOption { + type = lib.types.str; + default = "15G"; + example = "500M"; + description = '' + Free storage threshold to trigger the storage clear when bellow. + ''; + }; + }; }; }; @@ -134,7 +147,6 @@ in timerConfig = { OnUnitInactiveSec = cfg.pinger.schedule.minimum-wait; RandomizedDelaySec = cfg.pinger.schedule.random-delay; - Unit = "near-validator-pinger.service"; Persistent = true; }; }; @@ -173,5 +185,47 @@ in ''; } ); + + systemd.timers.near-validator-storage-clear = lib.mkIf cfg.storage-clear.enable { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnCalendar = "daily"; + RandomizedOffsetSec = "24h"; + Persistent = true; + }; + }; + + systemd.services.near-validator-storage-clear = + let + stateDir = "/var/lib/near-validator"; + in + { + description = "Remove NEAR validator storage if free space falls under threshold"; + after = [ "near-validator.target" ]; + wants = [ "near-validator.target" ]; + serviceConfig = { + Type = "oneshot"; + }; + path = [ + config.systemd.package + pkgs.gnused + ]; + script = + let + dataDir = "${stateDir}/.near/data"; + in + '' + free=$(df -B1 --output=avail "${dataDir}" | tail -1) + threshold=$(( $(echo "${cfg.storage-clear.min-free}" | sed 's/G$/000000000/;s/M$/000000/;s/K$/000/') )) + + if [ "$free" -ge "$threshold" ]; then + exit 0 + fi + + systemctl stop near-validator + rm -rf "${dataDir}" + systemctl start near-validator + ''; + }; }; }