nixfiles/hosts/hetzner-vm/containers/quassel/default.nix

76 lines
1.6 KiB
Nix
Raw Normal View History

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,
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
specialArgs = {
inherit inputs;
inherit tree;
2023-09-18 03:56:58 +01:00
inherit self;
inherit hostPath;
hostSecrets = secrets;
};
config = {config, ...}: {
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];
}