From 3cfc693b62021f49344c03b4167eefd1cd21197a Mon Sep 17 00:00:00 2001 From: noe Date: Fri, 22 Dec 2023 18:26:03 -0500 Subject: [PATCH] try an alternate pod approach --- nixos/hosts/blueberry/default.nix | 2 ++ nixos/stacks/ps2.live/default.nix | 5 +++++ nixos/stacks/ps2.live/saerro.nix | 10 ++++++++++ nixos/stacks/stack-utils.nix | 13 +++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 nixos/stacks/ps2.live/default.nix create mode 100644 nixos/stacks/ps2.live/saerro.nix create mode 100644 nixos/stacks/stack-utils.nix diff --git a/nixos/hosts/blueberry/default.nix b/nixos/hosts/blueberry/default.nix index 3c1b316..3b87f7a 100644 --- a/nixos/hosts/blueberry/default.nix +++ b/nixos/hosts/blueberry/default.nix @@ -5,6 +5,8 @@ ../../server.nix ../../features/systemd-boot.nix ../../features/podman.nix + + ../../stacks/ps2.live ]; networking.hostName = "blueberry"; diff --git a/nixos/stacks/ps2.live/default.nix b/nixos/stacks/ps2.live/default.nix new file mode 100644 index 0000000..7443c16 --- /dev/null +++ b/nixos/stacks/ps2.live/default.nix @@ -0,0 +1,5 @@ +{...}: { + imports = [ + ./saerro.nix + ]; +} diff --git a/nixos/stacks/ps2.live/saerro.nix b/nixos/stacks/ps2.live/saerro.nix new file mode 100644 index 0000000..ad5ded2 --- /dev/null +++ b/nixos/stacks/ps2.live/saerro.nix @@ -0,0 +1,10 @@ +{ ... }: let + podConfig = (import ../stack-utils.nix).pod "saerro" [ + "saerro_postgres" + "saerro_maint" + "saerro_api" + "saerro_ws" + ] [ 8003 ]; +in podConfig // { + +} diff --git a/nixos/stacks/stack-utils.nix b/nixos/stacks/stack-utils.nix new file mode 100644 index 0000000..b1664b9 --- /dev/null +++ b/nixos/stacks/stack-utils.nix @@ -0,0 +1,13 @@ +{ + pod = { pkgs, ... }: podName: containers: ports: { + systemd.services."ensure-pod_${podName}" = let + in { + serviceConfig.Type = "oneshot"; + wantedBy = map (x: "podman-${x}.service") containers; + script = '' + ${pkgs.podman}/bin/podman pod exists ${podName} || \\ + ${pkgs.podman}/bin/podman pod create -n ${podName} ${map (x: "-p 0.0.0.0:${x}:${x}") portFlags} + ''; + }; + }; +}