diff --git a/nixosModules/vds/3x-ui.nix b/nixosModules/vds/3x-ui.nix old mode 100755 new mode 100644 index ab60705..8899fa1 --- a/nixosModules/vds/3x-ui.nix +++ b/nixosModules/vds/3x-ui.nix @@ -1,17 +1,71 @@ +# Auto-generated using compose2nix v0.3.2-pre. +{ pkgs, lib, config, ... }: + { - config, - pkgs, - inputs, - ... -}: -let -in -{ - virtualisation = { - docker.enable = true; + # Runtime + virtualisation.podman = { + enable = true; + autoPrune.enable = true; + dockerCompat = true; }; - environment.systemPackages = [ - inputs.compose2nix.packages.x86_64-linux.default - ]; + # 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."3xui_app" = { + image = "localhost/compose2nix/3xui_app"; + environment = { + "XRAY_VMESS_AEAD_FORCED" = "false"; + "XUI_ENABLE_FAIL2BAN" = "true"; + }; + volumes = [ + "/home/oqyude/3x-ui/cert/:/root/cert:rw" + "/home/oqyude/3x-ui/db/:/etc/x-ui:rw" + ]; + log-driver = "journald"; + extraOptions = [ + "--network=host" + ]; + }; + systemd.services."podman-3xui_app" = { + serviceConfig = { + Restart = lib.mkOverride 90 "always"; + }; + partOf = [ + "podman-compose-3x-ui-root.target" + ]; + wantedBy = [ + "podman-compose-3x-ui-root.target" + ]; + }; + + # Builds + systemd.services."podman-build-3xui_app" = { + path = [ pkgs.podman pkgs.git ]; + serviceConfig = { + Type = "oneshot"; + TimeoutSec = 300; + }; + script = '' + cd /home/oqyude/3x-ui + podman build -t compose2nix/3xui_app -f ./Dockerfile . + ''; + }; + + # 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-3x-ui-root" = { + unitConfig = { + Description = "Root target generated by compose2nix."; + }; + wantedBy = [ "multi-user.target" ]; + }; } diff --git a/nixosModules/vds/default.nix b/nixosModules/vds/default.nix index 76d2f46..def8cdf 100755 --- a/nixosModules/vds/default.nix +++ b/nixosModules/vds/default.nix @@ -5,7 +5,7 @@ { imports = [ #./cloudflared.nix - ./3x-ui.nix + ./docker.nix ./netbird.nix ./nginx.nix ./xray.nix diff --git a/nixosModules/vds/docker.nix b/nixosModules/vds/docker.nix new file mode 100755 index 0000000..465d24e --- /dev/null +++ b/nixosModules/vds/docker.nix @@ -0,0 +1,19 @@ +{ + config, + pkgs, + inputs, + ... +}: +{ + imports = [ + #./3x-ui.nix + ]; + + virtualisation = { + docker.enable = true; + }; + + environment.systemPackages = [ + inputs.compose2nix.packages.x86_64-linux.default + ]; +}