2023-09-30 12:37:07 +01:00
|
|
|
{
|
|
|
|
self,
|
|
|
|
hostPath,
|
|
|
|
tree,
|
|
|
|
inputs,
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
containerName = "forgejo";
|
|
|
|
|
|
|
|
containerAddresses = import "${hostPath}/data/containerAddresses.nix";
|
|
|
|
|
|
|
|
hostIP = containerAddresses.host;
|
|
|
|
containerIP = containerAddresses.containers.${containerName};
|
|
|
|
|
|
|
|
pathInContainer = path: "/var/lib/nixos-containers/${containerName}" + path;
|
|
|
|
in {
|
|
|
|
containers.forgejo = {
|
|
|
|
autoStart = true;
|
|
|
|
privateNetwork = true;
|
|
|
|
hostAddress = hostIP;
|
|
|
|
localAddress = containerIP;
|
|
|
|
|
|
|
|
specialArgs = {
|
|
|
|
inherit inputs;
|
|
|
|
inherit tree;
|
|
|
|
inherit self;
|
|
|
|
inherit hostPath;
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {...}: {
|
|
|
|
nixpkgs.pkgs = pkgs;
|
|
|
|
|
|
|
|
imports = with tree;
|
|
|
|
[
|
|
|
|
presets.nixos.containerBase
|
|
|
|
profiles.sshd
|
|
|
|
profiles.firewallAllow.ssh
|
2023-10-02 03:08:24 +01:00
|
|
|
|
2023-09-30 16:49:52 +01:00
|
|
|
./secrets.nix
|
2023-09-30 12:37:07 +01:00
|
|
|
]
|
2023-09-30 16:49:52 +01:00
|
|
|
++ (with hosts.hetzner-arm.containers.forgejo.profiles; [
|
|
|
|
forgejo
|
|
|
|
restic
|
2023-09-30 12:37:07 +01:00
|
|
|
]);
|
|
|
|
|
|
|
|
networking.firewall.allowedTCPPorts = [2222];
|
|
|
|
|
|
|
|
home-manager.users.root.home.stateVersion = "23.05";
|
|
|
|
system.stateVersion = "23.05";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
networking = {
|
|
|
|
nat.forwardPorts = [
|
|
|
|
{
|
|
|
|
sourcePort = 2222;
|
|
|
|
destination = "${containerIP}\:2222";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
firewall.allowedTCPPorts = [2222];
|
|
|
|
};
|
|
|
|
|
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
virtualHosts."forgejo.owo.monster" = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
locations."/".proxyPass = "http://unix:${pathInContainer "/var/sockets/forgejo.sock"}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|