2023-08-01 20:53:25 +01:00
|
|
|
{
|
2023-09-18 03:56:58 +01:00
|
|
|
self,
|
|
|
|
hostPath,
|
2023-08-01 20:53:25 +01:00
|
|
|
tree,
|
|
|
|
lib,
|
|
|
|
inputs,
|
|
|
|
config,
|
2023-09-16 16:06:16 +01:00
|
|
|
pkgs,
|
2023-08-01 20:53:25 +01:00
|
|
|
...
|
|
|
|
}: let
|
2023-09-18 03:56:58 +01:00
|
|
|
containerAddresses = import "${hostPath}/data/containerAddresses.nix";
|
|
|
|
hostIP = containerAddresses.host;
|
|
|
|
containerIP = containerAddresses.containers.quassel;
|
|
|
|
|
|
|
|
containerLib = import "${self}/lib/containerLib.nix" {
|
|
|
|
inherit lib;
|
|
|
|
};
|
2023-08-01 20:53:25 +01:00
|
|
|
|
|
|
|
# Using secrets from Host
|
|
|
|
secrets = config.services.secrets.secrets;
|
2023-09-18 03:56:58 +01:00
|
|
|
secretsList = [
|
2023-08-01 20:53:25 +01:00
|
|
|
"quassel_restic_env"
|
|
|
|
"quassel_restic_password"
|
|
|
|
];
|
|
|
|
in {
|
|
|
|
containers.quassel = {
|
|
|
|
autoStart = true;
|
|
|
|
privateNetwork = true;
|
|
|
|
hostAddress = hostIP;
|
|
|
|
localAddress = containerIP;
|
2023-09-18 03:56:58 +01:00
|
|
|
bindMounts = containerLib.genBindHostsForSecrets secrets secretsList;
|
2023-08-01 20:53:25 +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
|
|
|
};
|
|
|
|
|
2023-09-11 23:22:18 +01:00
|
|
|
config = {config, ...}: {
|
2023-09-16 16:06:16 +01:00
|
|
|
nixpkgs.pkgs = pkgs;
|
2023-08-01 20:53:25 +01:00
|
|
|
|
|
|
|
imports = with tree;
|
|
|
|
[
|
2023-09-18 03:56:58 +01:00
|
|
|
presets.nixos.containerBase
|
2023-08-01 20:53:25 +01:00
|
|
|
profiles.sshd
|
2023-09-18 03:56:58 +01:00
|
|
|
profiles.firewallAllow.ssh
|
2023-08-01 20:53:25 +01:00
|
|
|
]
|
2023-09-18 03:56:58 +01:00
|
|
|
++ (with hosts.hetzner-vm.containers.quassel.profiles; [
|
|
|
|
quassel
|
|
|
|
restic
|
2023-08-01 20:53:25 +01:00
|
|
|
]);
|
|
|
|
|
|
|
|
# For Shared Secrets
|
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d ${config.services.secrets.secretsDir} - root root"
|
|
|
|
];
|
|
|
|
|
2023-09-18 03:56:58 +01:00
|
|
|
networking.firewall.allowedTCPPorts = [4242];
|
2023-08-01 20:53:25 +01:00
|
|
|
|
2023-09-18 03:56:58 +01:00
|
|
|
home-manager.users.root.home.stateVersion = "23.05";
|
2023-08-01 20:53:25 +01:00
|
|
|
system.stateVersion = "23.05";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-09-18 03:56:58 +01:00
|
|
|
networking.nat.forwardPorts = [
|
|
|
|
{
|
|
|
|
sourcePort = 4242;
|
|
|
|
destination = "${containerIP}\:4242";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2023-08-01 20:53:25 +01:00
|
|
|
networking.firewall.allowedTCPPorts = [4242];
|
|
|
|
}
|