flake/hosts/lightsail-tokyo/default.nix

57 lines
1.3 KiB
Nix
Raw Normal View History

2024-04-22 18:35:50 +00:00
{
modulesPath,
lib,
config,
2024-04-22 21:09:00 +00:00
inputs,
2024-04-22 18:35:50 +00:00
...
}: {
imports = [
"${modulesPath}/virtualisation/amazon-image.nix"
2024-04-22 21:09:00 +00:00
inputs.nixos-sensible.nixosModules.zram
2024-04-22 18:35:50 +00:00
../../nixos/profiles/server
./anti-feature.nix
];
time.timeZone = "Asia/Tokyo";
boot.loader.grub.device = lib.mkForce "/dev/nvme0n1";
system.stateVersion = "23.11";
### Services
sops.secrets = builtins.mapAttrs (_name: value:
value
// {
sopsFile = ./secrets.yaml;
restartUnits = ["hysteria.service"];
}) {
"hysteria/certificate" = {};
"hysteria/private-key" = {};
"hysteria/auth" = {};
};
sops.templates."hysteria.yaml".content = ''
2024-04-22 21:08:04 +00:00
tls:
cert: /run/credentials/hysteria.service/cert
key: /run/credentials/hysteria.service/key
2024-04-22 21:08:04 +00:00
masquerade:
type: proxy
proxy:
url: https://news.ycombinator.com/
rewriteHost: true
${config.sops.placeholder."hysteria/auth"}
'';
networking.firewall.allowedUDPPorts = [80 443];
networking.firewall.allowedTCPPorts = [80 443];
services.hysteria = {
enable = true;
configFile = config.sops.templates."hysteria.yaml".path;
credentials = [
"cert:${config.sops.secrets."hysteria/certificate".path}"
"key:${config.sops.secrets."hysteria/private-key".path}"
];
};
2024-04-22 18:35:50 +00:00
}