{ pkgs, lib, inputs, configVars, ... }: let containerName = "metrics-server"; containerIp = configVars.networking.addresses.metrics-server.ip; gatewayIp = configVars.networking.addresses.gateway.ip; metricsServerContainerData = configVars.locations.metricsServerContainerData; pubKeys = lib.filesystem.listFilesRecursive ../../users/keys; arion = inputs.arion; in { networking.nat.enable = true; networking.nat.internalInterfaces = ["ve-+"]; networking.nat.externalInterface = "br0"; services.restic.backups = { daily = { paths = [ metricsServerContainerData ]; exclude = [ ]; }; }; environment.persistence."/persist" = { hideMounts = true; directories = [ "/var/lib/nixos-containers/${containerName}" ]; }; containers."${containerName}" = { enableTun = true; autoStart = true; privateNetwork = true; hostBridge = "br0"; nixpkgs = pkgs.path; bindMounts = { "/var/lib/" = { hostPath = metricsServerContainerData; isReadOnly = false; }; }; config = { pkgs, lib, config, ... }: { networking = { defaultGateway = "${gatewayIp}"; interfaces.eth0.ipv4.addresses = [ { "address" = "${containerIp}"; "prefixLength" = 24; } ]; firewall = { enable = true; allowedTCPPorts = [ config.services.prometheus.port ]; }; useHostResolvConf = lib.mkForce false; }; services.resolved.enable = true; imports = [ ]; environment.systemPackages = [ pkgs.vim pkgs.git ]; services.prometheus = { enable = true; port = 9001; }; services.grafana = { enable = true; domain = "grafana.hm"; port = 2342; addr = "127.0.0.1"; }; services.nginx.virtualHosts.${config.services.grafana.domain} = { locations."/" = { proxyPass = "http://127.0.0.1:${toString config.services.grafana.port}"; proxyWebsockets = true; }; }; services.openssh = { enable = true; settings.PasswordAuthentication = false; }; users.users = { root = { openssh.authorizedKeys.keys = lib.lists.forEach pubKeys (key: builtins.readFile key); }; }; system.stateVersion = "24.05"; }; }; }