From c3f8acad128edffcc0e5b15940cc959bee0cd0ea Mon Sep 17 00:00:00 2001 From: oqyude Date: Sat, 4 Apr 2026 11:34:44 +0300 Subject: [PATCH] remnawave init --- configurations/disko/server.nix | 2 +- configurations/disko/vds.nix | 2 +- configurations/hardware/mini-laptop.nix | 10 +- configurations/hardware/server.nix | 10 +- configurations/hardware/vds.nix | 10 +- configurations/server.nix | 2 +- configurations/vds.nix | 2 +- modules/containers/remnawave.nix | 187 ++++++++++++++++++++++ modules/containers/secrets/remnawave.yaml | 20 +++ modules/server/default.nix | 4 +- modules/server/netdata.nix | 10 +- 11 files changed, 237 insertions(+), 22 deletions(-) create mode 100644 modules/containers/secrets/remnawave.yaml diff --git a/configurations/disko/server.nix b/configurations/disko/server.nix index 0e73e05..981057f 100644 --- a/configurations/disko/server.nix +++ b/configurations/disko/server.nix @@ -18,7 +18,7 @@ }; }; swap = { - size = "2G"; + size = "6G"; content = { type = "swap"; }; diff --git a/configurations/disko/vds.nix b/configurations/disko/vds.nix index c8210e5..bcc69ce 100644 --- a/configurations/disko/vds.nix +++ b/configurations/disko/vds.nix @@ -20,7 +20,7 @@ }; }; swap = { - size = "1G"; + size = "4G"; content = { type = "swap"; }; diff --git a/configurations/hardware/mini-laptop.nix b/configurations/hardware/mini-laptop.nix index 096a51d..b83f334 100644 --- a/configurations/hardware/mini-laptop.nix +++ b/configurations/hardware/mini-laptop.nix @@ -14,11 +14,11 @@ boot = { initrd = { - supportedFilesystems = [ - "nfs" - "nfsv4" - "overlay" - ]; + # supportedFilesystems = [ + # "nfs" + # "nfsv4" + # "overlay" + # ]; availableKernelModules = [ "nvme" "xhci_pci" diff --git a/configurations/hardware/server.nix b/configurations/hardware/server.nix index a4c066f..4823fcf 100644 --- a/configurations/hardware/server.nix +++ b/configurations/hardware/server.nix @@ -51,9 +51,13 @@ }; }; - # swapDevices = [ - # { device = "/dev/disk/by-partlabel/disk-main-swap"; } - # ]; + zramSwap = { + enable = true; + }; + + swapDevices = [ + { device = "/dev/disk/by-partlabel/disk-main-swap"; } + ]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking # (the default) this is the recommended approach. When using systemd-networkd it's diff --git a/configurations/hardware/vds.nix b/configurations/hardware/vds.nix index cdbee5a..dc81641 100644 --- a/configurations/hardware/vds.nix +++ b/configurations/hardware/vds.nix @@ -13,9 +13,13 @@ }; }; - # swapDevices = [ - # { device = "/dev/disk/by-partlabel/disk-main-swap"; } - # ]; + swapDevices = [ + { device = "/dev/disk/by-partlabel/disk-main-swap"; } + ]; + + zramSwap = { + enable = true; + }; networking.useDHCP = lib.mkDefault true; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; diff --git a/configurations/server.nix b/configurations/server.nix index 1ca6125..4be2e1d 100644 --- a/configurations/server.nix +++ b/configurations/server.nix @@ -20,7 +20,7 @@ let ]; boot = { - kernelPackages = pkgs.linuxPackages_xanmod_stable; + # kernelPackages = pkgs.linuxPackages_xanmod_stable; hardwareScan = true; loader = { systemd-boot.enable = lib.mkDefault true; diff --git a/configurations/vds.nix b/configurations/vds.nix index 7a9cf9c..6f873ed 100644 --- a/configurations/vds.nix +++ b/configurations/vds.nix @@ -26,7 +26,7 @@ let ]; boot = { - kernelPackages = pkgs.linuxPackages_xanmod_stable; + # kernelPackages = pkgs.linuxPackages_xanmod_stable; hardwareScan = true; loader = { grub = { diff --git a/modules/containers/remnawave.nix b/modules/containers/remnawave.nix index 9496e74..6498398 100644 --- a/modules/containers/remnawave.nix +++ b/modules/containers/remnawave.nix @@ -7,6 +7,193 @@ ... }: { + # Runtime + virtualisation.podman = { + enable = true; + autoPrune.enable = true; + dockerCompat = true; + }; + + # Enable container name DNS for all Podman networks. + networking.firewall.interfaces = let + matchAll = if !config.networking.nftables.enable then "podman+" else "podman*"; + in { + "${matchAll}".allowedUDPPorts = [ 53 ]; + }; + + virtualisation.oci-containers.backend = "podman"; + + # Containers + virtualisation.oci-containers.containers."remnawave-panel-1" = { + image = "ghcr.io/remnawave/backend:latest"; + environment = { + "API_INSTANCES" = "1"; + "APP_PORT" = "3000"; + "BANDWIDTH_USAGE_NOTIFICATIONS_ENABLED" = "false"; + "BANDWIDTH_USAGE_NOTIFICATIONS_THRESHOLD" = "[60, 80]"; + "FRONT_END_DOMAIN" = "*"; + "IS_DOCS_ENABLED" = "false"; + "IS_TELEGRAM_NOTIFICATIONS_ENABLED" = "false"; + "METRICS_PASS" = "admin"; + "METRICS_PORT" = "3001"; + "METRICS_USER" = "admin"; + "NOT_CONNECTED_USERS_NOTIFICATIONS_AFTER_HOURS" = "[6, 24, 48]"; + "NOT_CONNECTED_USERS_NOTIFICATIONS_ENABLED" = "false"; + "PANEL_DOMAIN" = "rw.zeroq.ru"; + "POSTGRES_DB" = "remnawave"; + "POSTGRES_USER" = "remnawave"; + "REDIS_SOCKET" = "/var/run/valkey/valkey.sock"; + "SCALAR_PATH" = "/scalar"; + "SUB_PUBLIC_DOMAIN" = "rw.zeroq.ru/api/sub"; + "SWAGGER_PATH" = "/docs"; + # "TELEGRAM_BOT_TOKEN" = "change_me"; + # "TELEGRAM_NOTIFY_CRM" = "change_me"; + # "TELEGRAM_NOTIFY_NODES" = "change_me"; + # "TELEGRAM_NOTIFY_SERVICE" = "change_me"; + # "TELEGRAM_NOTIFY_TBLOCKER" = "change_me"; + # "TELEGRAM_NOTIFY_USERS" = "change_me"; + "WEBHOOK_ENABLED" = "false"; + # "WEBHOOK_URL" = "https://your-webhook-url.com/endpoint"; + }; + environmentFiles = [ + "/run/secrets/remnawave-env" + ]; + ports = [ + "3003:3003/tcp" + ]; + log-driver = "journald"; + extraOptions = [ + "--network-alias=remnawave-panel-1" + "--network=host" # "--network=remnawavebackend_default" + ]; + }; + systemd.services."podman-remnawave-panel-1" = { + serviceConfig = { + Restart = lib.mkOverride 90 "always"; + }; + partOf = [ + "podman-compose-remnawave-root.target" + ]; + wantedBy = [ + "podman-compose-remnawave-root.target" + ]; + }; + + # Builds + # systemd.services."podman-build-remnawave-panel-1" = { + # path = [ pkgs.podman pkgs.git ]; + # serviceConfig = { + # Type = "oneshot"; + # TimeoutSec = 300; + # }; + # script = '' + # cd /mnt/s/Deploy/remnawave-backend + # podman build -t compose2nix/remnawave-panel-1 . + # ''; + # }; + + # Root service + # When started, this will automatically create all resources and start + # the containers. When stopped, this will teardown all resources. + systemd.targets."podman-compose-remnawave-root" = { + unitConfig = { + Description = "Root target generated by compose2nix."; + }; + wantedBy = [ "multi-user.target" ]; + }; + + services = { + postgresql = { + ensureDatabases = [ "remnawave" ]; + ensureUsers = [ + { + name = "remnawave"; + ensureDBOwnership = true; + } + ]; + }; + }; + + systemd.services = { + remnawave-env = { + description = "Generate remnawave env file"; + requiredBy = [ "podman-remnawave-panel-1.service" ]; + before = [ "podman-remnawave-panel-1.service" ]; + serviceConfig = { + Type = "oneshot"; + User = "root"; + }; + script = '' + cat > /run/secrets/remnawave-env <