feat(kitchenowl): add to container options
This commit is contained in:
parent
44331c9146
commit
de8bd2cf4d
3 changed files with 167 additions and 18 deletions
|
@ -19,7 +19,14 @@
|
|||
efiInstallAsRemovable = true;
|
||||
};
|
||||
|
||||
modules.server.paperless = {
|
||||
modules = {
|
||||
container.kitchenowl = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
};
|
||||
|
||||
server = {
|
||||
paperless = {
|
||||
enable = true;
|
||||
openPort = true;
|
||||
settings = {
|
||||
|
@ -27,7 +34,7 @@
|
|||
};
|
||||
};
|
||||
|
||||
modules.server.navidrome = {
|
||||
navidrome = {
|
||||
enable = true;
|
||||
library = {
|
||||
path = "/mnt/music";
|
||||
|
@ -42,6 +49,8 @@
|
|||
Port = 4533;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
openssh.enable = true;
|
||||
|
|
|
@ -4,6 +4,8 @@ let
|
|||
inherit (lib) mkIf mkEnableOption;
|
||||
in
|
||||
{
|
||||
imports = [ ./kitchenowl ];
|
||||
|
||||
options.modules.container = {
|
||||
enable = mkEnableOption "container support";
|
||||
};
|
||||
|
|
138
options/container/kitchenowl/default.nix
Normal file
138
options/container/kitchenowl/default.nix
Normal file
|
@ -0,0 +1,138 @@
|
|||
{
|
||||
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" ];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue