from my phone so i cant see the changes lol
This commit is contained in:
70
modules/containers/nginx-ha/container.nix
Normal file
70
modules/containers/nginx-ha/container.nix
Normal file
@@ -0,0 +1,70 @@
|
||||
{moduleWithSystem, ...}: {
|
||||
flake.nixosModules.containerNginxHomeAssistant = moduleWithSystem ({
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
virtualisation.oci-containers.containers."nginx-home-assistant" = {
|
||||
image = "lscr.io/linuxserver/nginx:latest";
|
||||
environment = {
|
||||
"NGINX_AUTORELOAD" = "true";
|
||||
"PGID" = "0";
|
||||
"PUID" = "0";
|
||||
"TZ" = "Etc/UTC";
|
||||
};
|
||||
volumes = [
|
||||
"/containers/nginx-ha/config:/config:rw"
|
||||
];
|
||||
ports = [
|
||||
"8123:80/tcp"
|
||||
];
|
||||
log-driver = "journald";
|
||||
extraOptions = [
|
||||
"--network-alias=nginx"
|
||||
"--network=nginx-ha_default"
|
||||
];
|
||||
};
|
||||
systemd.services."podman-nginx-home-assistant" = {
|
||||
serviceConfig = {
|
||||
Restart = pkgs.lib.mkOverride 90 "always";
|
||||
};
|
||||
after = [
|
||||
"podman-network-nginx-ha_default.service"
|
||||
];
|
||||
requires = [
|
||||
"podman-network-nginx-ha_default.service"
|
||||
];
|
||||
partOf = [
|
||||
"podman-compose-nginx-ha-root.target"
|
||||
];
|
||||
wantedBy = [
|
||||
"podman-compose-nginx-ha-root.target"
|
||||
];
|
||||
};
|
||||
|
||||
# Networks
|
||||
systemd.services."podman-network-nginx-ha_default" = {
|
||||
path = [ pkgs.podman ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
ExecStop = "podman network rm -f nginx-ha_default";
|
||||
};
|
||||
script = ''
|
||||
podman network inspect nginx-ha_default || podman network create nginx-ha_default
|
||||
'';
|
||||
partOf = [ "podman-compose-nginx-ha-root.target" ];
|
||||
wantedBy = [ "podman-compose-nginx-ha-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."podman-compose-nginx-ha-root" = {
|
||||
unitConfig = {
|
||||
Description = "Root target generated by compose2nix.";
|
||||
};
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
};
|
||||
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user