Reformat attic-collect-garbage

This commit is contained in:
Andreas Zweili 2024-04-17 20:06:08 +02:00
parent 062de15f1a
commit ea2af91d70
1 changed files with 21 additions and 11 deletions

View File

@ -11,16 +11,26 @@ let
cacheStorage = "/mnt/binary-cache"; cacheStorage = "/mnt/binary-cache";
atticPort = 8080; atticPort = 8080;
atticDomain = "cache.zweili.org"; atticDomain = "cache.zweili.org";
attic-garbage-collect = pkgs.writeShellScriptBin "attic-garbage-collect" '' atticCollectGarbage = pkgs.writeShellScriptBin "attic-collect-garbage" ''
${ ATTICD=${inputs.attic.packages.${system}.attic-server}/bin/atticd
inputs.attic.packages.${system}.attic-server
}/bin/atticd --config ${config.services.atticd.configFile} --mode garbage-collector-once exec ${pkgs.systemd}/bin/systemd-run \
# Fail if $SUDO_USER is empty. --quiet \
if [ -z "$SUDO_USER" ]; then --pty \
printf "This script must be run with sudo.\n" --same-dir \
exit 1 --wait \
fi --collect \
source ${config.services.atticd.credentialsFile} --service-type=exec \
--property=EnvironmentFile=${config.services.atticd.credentialsFile} \
--property=DynamicUser=yes \
--property=User=${config.services.atticd.user} \
--property=Environment=ATTICADM_PWD=$(pwd) \
--property=ReadWritePaths=${config.services.atticd.settings.storage.path} \
--working-directory / \
-- \
$ATTICD \
--config ${config.services.atticd.configFile} \
--mode garbage-collector-once
''; '';
in in
{ {
@ -46,7 +56,7 @@ in
}; };
environment.systemPackages = [ environment.systemPackages = [
inputs.attic.packages.${system}.attic-client inputs.attic.packages.${system}.attic-client
attic-garbage-collect atticCollectGarbage
]; ];
networking.firewall.allowedTCPPorts = [ 443 ]; networking.firewall.allowedTCPPorts = [ 443 ];