138 lines
3.7 KiB
Nix
138 lines
3.7 KiB
Nix
{
|
|
lib,
|
|
pkgs,
|
|
config,
|
|
...
|
|
}:
|
|
let
|
|
inherit (lib) mkIf mkOption mkEnableOption;
|
|
inherit (lib.types) port bool;
|
|
cfg = config.modules.container.kitchenowl;
|
|
in
|
|
{
|
|
options.modules.container.kitchenowl = {
|
|
enable = mkEnableOption "Whether to enable the kitchenowl container";
|
|
port = mkOption {
|
|
type = port;
|
|
default = 82;
|
|
};
|
|
openFirewall = mkOption {
|
|
type = bool;
|
|
default = false;
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
modules.container.enable = true;
|
|
|
|
networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ];
|
|
|
|
# Containers
|
|
virtualisation.oci-containers.containers."kitchenowl-back" = {
|
|
image = "tombursch/kitchenowl:latest";
|
|
environment = {
|
|
"JWT_SECRET_KEY" = "PLEASE_CHANGE_ME";
|
|
};
|
|
volumes = [
|
|
"kitchenowl_kitchenowl_data:/data:rw"
|
|
];
|
|
log-driver = "journald";
|
|
extraOptions = [
|
|
"--network-alias=back"
|
|
"--network=kitchenowl_default"
|
|
];
|
|
};
|
|
virtualisation.oci-containers.containers."kitchenowl-front" = {
|
|
image = "tombursch/kitchenowl-web:latest";
|
|
ports = [
|
|
"${toString cfg.port}:80/tcp"
|
|
];
|
|
dependsOn = [
|
|
"kitchenowl-back"
|
|
];
|
|
log-driver = "journald";
|
|
extraOptions = [
|
|
"--hostname=kitchenowl"
|
|
"--network-alias=front"
|
|
"--network=kitchenowl_default"
|
|
];
|
|
};
|
|
|
|
systemd.services."podman-kitchenowl-back" = {
|
|
serviceConfig = {
|
|
Restart = lib.mkOverride 500 "always";
|
|
};
|
|
after = [
|
|
"podman-network-kitchenowl_default.service"
|
|
"podman-volume-kitchenowl_kitchenowl_data.service"
|
|
];
|
|
requires = [
|
|
"podman-network-kitchenowl_default.service"
|
|
"podman-volume-kitchenowl_kitchenowl_data.service"
|
|
];
|
|
partOf = [
|
|
"podman-compose-kitchenowl-root.target"
|
|
];
|
|
wantedBy = [
|
|
"podman-compose-kitchenowl-root.target"
|
|
];
|
|
};
|
|
|
|
systemd.services."podman-kitchenowl-front" = {
|
|
serviceConfig = {
|
|
Restart = lib.mkOverride 500 "always";
|
|
};
|
|
after = [
|
|
"podman-network-kitchenowl_default.service"
|
|
];
|
|
requires = [
|
|
"podman-network-kitchenowl_default.service"
|
|
];
|
|
partOf = [
|
|
"podman-compose-kitchenowl-root.target"
|
|
];
|
|
wantedBy = [
|
|
"podman-compose-kitchenowl-root.target"
|
|
];
|
|
};
|
|
|
|
# Networks
|
|
systemd.services."podman-network-kitchenowl_default" = {
|
|
path = [ pkgs.podman ];
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
RemainAfterExit = true;
|
|
ExecStop = "podman network rm -f kitchenowl_default";
|
|
};
|
|
script = ''
|
|
podman network inspect kitchenowl_default || podman network create kitchenowl_default
|
|
'';
|
|
partOf = [ "podman-compose-kitchenowl-root.target" ];
|
|
wantedBy = [ "podman-compose-kitchenowl-root.target" ];
|
|
};
|
|
|
|
# Volumes
|
|
systemd.services."podman-volume-kitchenowl_kitchenowl_data" = {
|
|
path = [ pkgs.podman ];
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
RemainAfterExit = true;
|
|
};
|
|
script = ''
|
|
podman volume inspect kitchenowl_kitchenowl_data || podman volume create kitchenowl_kitchenowl_data
|
|
'';
|
|
partOf = [ "podman-compose-kitchenowl-root.target" ];
|
|
wantedBy = [ "podman-compose-kitchenowl-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-kitchenowl-root" = {
|
|
unitConfig = {
|
|
Description = "Root target generated by compose2nix.";
|
|
};
|
|
wantedBy = [ "multi-user.target" ];
|
|
};
|
|
};
|
|
}
|