diff --git a/hosts/nixos/common/global/ports.nix b/hosts/nixos/common/global/ports.nix index 49bbaee..21a0581 100644 --- a/hosts/nixos/common/global/ports.nix +++ b/hosts/nixos/common/global/ports.nix @@ -25,5 +25,6 @@ guacamole = 8421; syncthing = 8422; forgejo-ssh = 8423; + "5d-diplomacy" = 8424; }; } diff --git a/hosts/nixos/common/optional/oci.nix b/hosts/nixos/common/optional/oci.nix index 858bd8b..b8520a5 100644 --- a/hosts/nixos/common/optional/oci.nix +++ b/hosts/nixos/common/optional/oci.nix @@ -1,6 +1,11 @@ { virtualisation.oci-containers.backend = "docker"; + virtualisation.docker = { + enable = true; + autoPrune.enable = true; + }; + environment.persistence = { "/persist/state".directories = [ "/var/lib/containers/storage" ]; "/persist/local/cache".directories = [ "/var/lib/containers/cache" ]; diff --git a/hosts/nixos/lapetus/default.nix b/hosts/nixos/lapetus/default.nix index 26ffd37..0da105c 100644 --- a/hosts/nixos/lapetus/default.nix +++ b/hosts/nixos/lapetus/default.nix @@ -19,14 +19,16 @@ # ./services/commafeed.nix # ./services/ddclient.nix + # ./services/guacamole + # ./services/intray.nix + # ./services/smos.nix + ./services/5d-diplomacy ./services/actual.nix ./services/cloudflared.nix ./services/diptime.nix ./services/forgejo.nix ./services/grafana.nix - ./services/guacamole ./services/homer.nix - # ./services/intray.nix ./services/invidious.nix ./services/jellyfin.nix ./services/jupyter.nix @@ -34,10 +36,9 @@ ./services/pounce.nix ./services/prometheus.nix ./services/prometheus.nix - ./services/qbittorrent.nix # turned on/off depending on whether my vpn is paid for + ./services/qbittorrent.nix ./services/radicale.nix ./services/redlib.nix - # ./services/smos.nix ./services/vaultwarden.nix ./services/whoogle.nix ./services/zfs.nix diff --git a/hosts/nixos/lapetus/services/5d-diplomacy/default.nix b/hosts/nixos/lapetus/services/5d-diplomacy/default.nix new file mode 100644 index 0000000..f2687f8 --- /dev/null +++ b/hosts/nixos/lapetus/services/5d-diplomacy/default.nix @@ -0,0 +1,9 @@ +{ config, ... }: +{ + imports = [ ./generated.nix ]; + + satellite.cloudflared.at.dip.port = config.satellite.ports."5d-diplomacy"; + virtualisation.oci-containers.containers."5d-diplomacy-frontend".ports = [ + "${toString config.satellite.ports."5d-diplomacy"}:8080" + ]; +} diff --git a/hosts/nixos/lapetus/services/5d-diplomacy/generated.nix b/hosts/nixos/lapetus/services/5d-diplomacy/generated.nix new file mode 100644 index 0000000..e3d11f3 --- /dev/null +++ b/hosts/nixos/lapetus/services/5d-diplomacy/generated.nix @@ -0,0 +1,150 @@ +# Auto-generated using compose2nix v0.3.1-pre. +{ pkgs, lib, ... }: + +{ + # Containers + virtualisation.oci-containers.containers."5d-diplomacy-backend" = { + image = "localhost/compose2nix-5d-diplomacy-backend"; + environment = { + "ConnectionStrings__Database" = "Server=mssql;Database=diplomacy;User=SA;Password=Passw0rd@;Encrypt=True;TrustServerCertificate=True"; + }; + log-driver = "journald"; + extraOptions = [ + "--network-alias=backend" + "--network=5d-diplomacy_default" + ]; + }; + systemd.services."docker-5d-diplomacy-backend" = { + serviceConfig = { + Restart = lib.mkOverride 90 "always"; + RestartMaxDelaySec = lib.mkOverride 90 "1m"; + RestartSec = lib.mkOverride 90 "100ms"; + RestartSteps = lib.mkOverride 90 9; + }; + after = [ + "docker-build-5d-diplomacy-backend.service" + "docker-network-5d-diplomacy_default.service" + ]; + requires = [ + "docker-build-5d-diplomacy-backend.service" + "docker-network-5d-diplomacy_default.service" + ]; + partOf = [ "docker-compose-5d-diplomacy-root.target" ]; + wantedBy = [ "docker-compose-5d-diplomacy-root.target" ]; + }; + virtualisation.oci-containers.containers."5d-diplomacy-frontend" = { + image = "localhost/compose2nix-5d-diplomacy-frontend"; + ports = [ "127.0.0.1:5173:8080/tcp" ]; + log-driver = "journald"; + extraOptions = [ + "--network-alias=frontend" + "--network=5d-diplomacy_default" + ]; + }; + systemd.services."docker-5d-diplomacy-frontend" = { + serviceConfig = { + Restart = lib.mkOverride 90 "always"; + RestartMaxDelaySec = lib.mkOverride 90 "1m"; + RestartSec = lib.mkOverride 90 "100ms"; + RestartSteps = lib.mkOverride 90 9; + }; + after = [ + "docker-build-5d-diplomacy-frontend.service" + "docker-network-5d-diplomacy_default.service" + ]; + requires = [ + "docker-build-5d-diplomacy-frontend.service" + "docker-network-5d-diplomacy_default.service" + ]; + partOf = [ "docker-compose-5d-diplomacy-root.target" ]; + wantedBy = [ "docker-compose-5d-diplomacy-root.target" ]; + }; + virtualisation.oci-containers.containers."5d-diplomacy-mssql" = { + image = "mcr.microsoft.com/mssql/server:2022-latest"; + environment = { + "ACCEPT_EULA" = "y"; + "MSSQL_SA_PASSWORD" = "Passw0rd@"; + }; + volumes = [ + "/home/moon/projects/5d-diplomacy-with-multiverse-time-travel/mssql-data/data:/var/opt/mssql/data:rw" + "/home/moon/projects/5d-diplomacy-with-multiverse-time-travel/mssql-data/log:/var/opt/mssql/log:rw" + "/home/moon/projects/5d-diplomacy-with-multiverse-time-travel/mssql-data/secrets:/var/opt/mssql/secrets:rw" + ]; + user = "root"; + log-driver = "journald"; + extraOptions = [ + "--network-alias=mssql" + "--network=5d-diplomacy_default" + ]; + }; + systemd.services."docker-5d-diplomacy-mssql" = { + serviceConfig = { + Restart = lib.mkOverride 90 "no"; + }; + after = [ "docker-network-5d-diplomacy_default.service" ]; + requires = [ "docker-network-5d-diplomacy_default.service" ]; + partOf = [ "docker-compose-5d-diplomacy-root.target" ]; + wantedBy = [ "docker-compose-5d-diplomacy-root.target" ]; + }; + + # Networks + systemd.services."docker-network-5d-diplomacy_default" = { + path = [ pkgs.docker ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + ExecStop = "docker network rm -f 5d-diplomacy_default"; + }; + script = '' + docker network inspect 5d-diplomacy_default || docker network create 5d-diplomacy_default + ''; + partOf = [ "docker-compose-5d-diplomacy-root.target" ]; + wantedBy = [ "docker-compose-5d-diplomacy-root.target" ]; + }; + + # Builds + systemd.services."docker-build-5d-diplomacy-backend" = { + path = [ + pkgs.docker + pkgs.git + ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + TimeoutSec = 300; + }; + script = '' + cd /home/moon/projects/5d-diplomacy-with-multiverse-time-travel/server + docker build -t compose2nix-5d-diplomacy-backend . + ''; + partOf = [ "docker-compose-5d-diplomacy-root.target" ]; + wantedBy = [ "docker-compose-5d-diplomacy-root.target" ]; + }; + systemd.services."docker-build-5d-diplomacy-frontend" = { + path = [ + pkgs.docker + pkgs.git + ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + TimeoutSec = 300; + }; + script = '' + cd /home/moon/projects/5d-diplomacy-with-multiverse-time-travel/client + docker build -t compose2nix-5d-diplomacy-frontend . + ''; + partOf = [ "docker-compose-5d-diplomacy-root.target" ]; + wantedBy = [ "docker-compose-5d-diplomacy-root.target" ]; + }; + + # Root service + # When started, this will automatically create all resources and start + # the containers. When stopped, this will teardown all resources. + systemd.targets."docker-compose-5d-diplomacy-root" = { + unitConfig = { + Description = "Root target generated by compose2nix."; + }; + wantedBy = [ "multi-user.target" ]; + }; +}