oizys/hosts/algiz/services.nix

86 lines
2.2 KiB
Nix
Raw Normal View History

2025-01-19 18:42:48 -06:00
{
pkgs,
enabled,
flake,
...
}:
2024-10-29 16:58:36 -05:00
let
atticPort = "5656";
static = pkgs.runCommandLocal "static-files" { } ''
mkdir $out
cp ${./caddy/index.html} $out/index.html
'';
2024-10-29 16:58:36 -05:00
in
{
services.resolved = enabled;
services.fail2ban = enabled // {
maxretry = 5;
bantime = "24h";
};
services.openssh = enabled // {
settings.PasswordAuthentication = false;
};
security.polkit = enabled; # attic was looking for this...
2025-01-20 13:48:24 -06:00
environment.systemPackages = [ (flake.pkgs "self").attic-client ];
2024-10-29 16:58:36 -05:00
# allow docker to forward the request to the host running attic
# https://discourse.nixos.org/t/docker-container-not-resolving-to-host/30259/6
# networking.firewall.extraCommands = "iptables -A INPUT -p tcp --destination-port ${atticPort} -s 172.16.0.0/12 -j ACCEPT";
2024-10-29 16:58:36 -05:00
services.atticd = enabled // {
2025-01-20 13:48:24 -06:00
package = (flake.pkgs "self").attic-server;
2025-01-19 18:21:44 -06:00
2024-10-29 16:58:36 -05:00
# Replace with absolute path to your credentials file
2025-01-19 18:42:48 -06:00
# TODO: replace with sops-secret!
2024-10-29 16:58:36 -05:00
environmentFile = "/etc/atticd.env";
settings = {
listen = "[::]:${atticPort}";
jwt = { };
# Data chunking
#
# Warning: If you change any of the values here, it will be
# difficult to reuse existing chunks for newly-uploaded NARs
# since the cutpoints will be different. As a result, the
# deduplication ratio will suffer for a while after the change.
chunking = {
# The minimum NAR size to trigger chunking
#
# If 0, chunking is disabled entirely for newly-uploaded NARs.
# If 1, all NARs are chunked.
nar-size-threshold = 64 * 1024; # 64 KiB
# The preferred minimum size of a chunk, in bytes
min-size = 16 * 1024; # 16 KiB
# The preferred average size of a chunk, in bytes
avg-size = 64 * 1024; # 64 KiB
# The preferred maximum size of a chunk, in bytes
max-size = 256 * 1024; # 256 KiB
};
};
};
2024-11-05 21:39:52 -06:00
services.caddy = enabled // {
extraConfig = builtins.readFile ./caddy/Caddyfile;
virtualHosts."attic.dayl.in".extraConfig = ''
redir /oizys /
handle / {
root * ${static}
file_server
2024-11-05 21:39:52 -06:00
}
handle /* {
reverse_proxy http://localhost:5656
}
'';
};
2024-10-29 16:58:36 -05:00
}