103 lines
2.5 KiB
Nix
103 lines
2.5 KiB
Nix
|
# Auto-generated using compose2nix v0.3.2-pre.
|
||
|
{
|
||
|
config,
|
||
|
pkgs,
|
||
|
lib,
|
||
|
...
|
||
|
}:
|
||
|
|
||
|
with lib;
|
||
|
|
||
|
let
|
||
|
cfg = config.features.homelab.beaverhabits;
|
||
|
|
||
|
port = 8084;
|
||
|
in
|
||
|
{
|
||
|
options.features.homelab.beaverhabits.enable = mkEnableOption "Enable beaverhabits";
|
||
|
|
||
|
config = mkIf cfg.enable {
|
||
|
virtualisation = {
|
||
|
docker = {
|
||
|
enable = true;
|
||
|
autoPrune.enable = true;
|
||
|
};
|
||
|
|
||
|
oci-containers = {
|
||
|
backend = "docker";
|
||
|
|
||
|
containers."beaverhabits" = {
|
||
|
image = "daya0576/beaverhabits:latest";
|
||
|
|
||
|
environment = {
|
||
|
"HABITS_STORAGE" = "DATABASE";
|
||
|
};
|
||
|
|
||
|
volumes = [
|
||
|
"/mnt/media/beaverhabits:/app/.user:rw"
|
||
|
];
|
||
|
|
||
|
ports = [
|
||
|
"${toString port}:8080/tcp"
|
||
|
];
|
||
|
|
||
|
user = "1000:1000";
|
||
|
|
||
|
log-driver = "journald";
|
||
|
|
||
|
extraOptions = [
|
||
|
"--network-alias=beaverhabits"
|
||
|
"--network=beaverhabits_default"
|
||
|
];
|
||
|
};
|
||
|
};
|
||
|
};
|
||
|
|
||
|
systemd = {
|
||
|
services = {
|
||
|
"docker-beaverhabits" = {
|
||
|
serviceConfig = {
|
||
|
Restart = lib.mkOverride 90 "always";
|
||
|
RestartMaxDelaySec = lib.mkOverride 90 "1m";
|
||
|
RestartSec = lib.mkOverride 90 "100ms";
|
||
|
RestartSteps = lib.mkOverride 90 9;
|
||
|
};
|
||
|
|
||
|
after = [ "docker-network-beaverhabits_default.service" ];
|
||
|
requires = [ "docker-network-beaverhabits_default.service" ];
|
||
|
partOf = [ "docker-compose-beaverhabits-root.target" ];
|
||
|
wantedBy = [ "docker-compose-beaverhabits-root.target" ];
|
||
|
};
|
||
|
|
||
|
"docker-network-beaverhabits_default" = {
|
||
|
path = [ pkgs.docker ];
|
||
|
|
||
|
serviceConfig = {
|
||
|
Type = "oneshot";
|
||
|
RemainAfterExit = true;
|
||
|
ExecStop = "docker network rm -f beaverhabits_default";
|
||
|
};
|
||
|
|
||
|
script = ''
|
||
|
docker network inspect beaverhabits_default || docker network create beaverhabits_default
|
||
|
'';
|
||
|
|
||
|
partOf = [ "docker-compose-beaverhabits-root.target" ];
|
||
|
wantedBy = [ "docker-compose-beaverhabits-root.target" ];
|
||
|
};
|
||
|
};
|
||
|
|
||
|
targets."docker-compose-beaverhabits-root" = {
|
||
|
unitConfig.Description = "Root target generated by compose2nix.";
|
||
|
wantedBy = [ "multi-user.target" ];
|
||
|
};
|
||
|
};
|
||
|
|
||
|
services.caddy.virtualHosts."beaverhabits.opdavies.uk" = {
|
||
|
useACMEHost = "opdavies.uk";
|
||
|
|
||
|
extraConfig = "reverse_proxy localhost:${toString port}";
|
||
|
};
|
||
|
};
|
||
|
}
|