2023-07-29 16:41:20 +01:00
|
|
|
{
|
2023-09-18 03:56:58 +01:00
|
|
|
self,
|
|
|
|
hostPath,
|
2023-07-29 16:41:20 +01:00
|
|
|
tree,
|
|
|
|
inputs,
|
|
|
|
config,
|
2023-09-16 16:06:16 +01:00
|
|
|
pkgs,
|
2023-07-29 16:41:20 +01:00
|
|
|
...
|
|
|
|
}: let
|
2023-09-18 03:56:58 +01:00
|
|
|
containerAddresses = import "${hostPath}/data/containerAddresses.nix";
|
|
|
|
hostIP = containerAddresses.host;
|
|
|
|
containerIP = containerAddresses.containers.social;
|
2023-07-29 16:41:20 +01:00
|
|
|
|
|
|
|
# Using secrets from Host
|
|
|
|
secrets = config.services.secrets.secrets;
|
|
|
|
in {
|
|
|
|
containers.social = {
|
|
|
|
autoStart = true;
|
|
|
|
privateNetwork = true;
|
|
|
|
hostAddress = hostIP;
|
|
|
|
localAddress = containerIP;
|
|
|
|
bindMounts = {
|
|
|
|
"${secrets.social_restic_password.path}" = {
|
|
|
|
hostPath = "${secrets.social_restic_password.path}";
|
|
|
|
};
|
|
|
|
"${secrets.social_restic_env.path}" = {
|
|
|
|
hostPath = "${secrets.social_restic_env.path}";
|
|
|
|
};
|
2023-09-02 18:17:03 +01:00
|
|
|
"${secrets.social_env_secrets.path}" = {
|
|
|
|
hostPath = "${secrets.social_env_secrets.path}";
|
|
|
|
};
|
2023-07-29 16:41:20 +01:00
|
|
|
};
|
|
|
|
|
2023-09-16 16:06:16 +01:00
|
|
|
specialArgs = {
|
|
|
|
inherit inputs;
|
|
|
|
inherit tree;
|
2023-09-18 03:56:58 +01:00
|
|
|
inherit self;
|
|
|
|
inherit hostPath;
|
|
|
|
hostSecrets = secrets;
|
2023-09-16 16:06:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = {config, ...}: {
|
|
|
|
nixpkgs.pkgs = pkgs;
|
2023-07-29 16:41:20 +01:00
|
|
|
|
|
|
|
imports = with tree;
|
|
|
|
[
|
|
|
|
profiles.base
|
|
|
|
inputs.home-manager-unstable.nixosModules.home-manager
|
|
|
|
|
|
|
|
profiles.sshd
|
|
|
|
|
|
|
|
modules.nixos.secrets
|
|
|
|
|
|
|
|
users.root
|
|
|
|
]
|
|
|
|
++ (with hosts.hetzner-vm.containers.social; [
|
|
|
|
profiles.gotosocial
|
2023-09-20 18:17:50 +01:00
|
|
|
profiles.restic
|
2023-07-29 16:41:20 +01:00
|
|
|
]);
|
|
|
|
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
rclone
|
|
|
|
restic
|
|
|
|
];
|
|
|
|
|
|
|
|
# For Shared Secrets
|
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d ${config.services.secrets.secretsDir} - root root"
|
|
|
|
];
|
|
|
|
|
|
|
|
networking.firewall = {
|
|
|
|
enable = true;
|
|
|
|
allowedTCPPorts = [22 8080];
|
|
|
|
};
|
|
|
|
|
|
|
|
home-manager.users.root = {
|
|
|
|
imports = with tree; [home.base home.dev.small];
|
2023-09-11 23:22:18 +01:00
|
|
|
home.stateVersion = "23.05";
|
2023-07-29 16:41:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
# Manually configure nameserver. Using resolved inside the container seems to fail
|
|
|
|
# currently
|
|
|
|
environment.etc."resolv.conf".text = "nameserver 8.8.8.8";
|
2023-09-11 23:22:18 +01:00
|
|
|
system.stateVersion = "23.05";
|
2023-07-29 16:41:20 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.nginx.virtualHosts."gts-01.owo.monster" = {
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://${containerIP}:8080";
|
2023-09-02 16:10:12 +01:00
|
|
|
proxyWebsockets = true;
|
2023-07-29 16:41:20 +01:00
|
|
|
extraConfig = ''
|
2023-09-02 17:42:27 +01:00
|
|
|
# uncomment if running nginx without recommendedProxySettings
|
|
|
|
# proxy_set_header Host $host;
|
|
|
|
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
# proxy_set_header X-Forwarded-Proto $scheme;
|
2023-07-29 16:41:20 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
extraConfig = ''
|
|
|
|
client_max_body_size 128M;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|