docs: initialize NixOS infrastructure with AI assistant
Creates PROJECT.md with vision and requirements. Creates config.json with interactive workflow mode.
This commit is contained in:
36
modules/nixos/services/docker_manager.nix
Normal file
36
modules/nixos/services/docker_manager.nix
Normal file
@@ -0,0 +1,36 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
options.services.myDockerStacks = mkOption {
|
||||
type = types.attrsOf (types.submodule {
|
||||
options = {
|
||||
path = mkOption { type = types.path; };
|
||||
ports = mkOption { type = types.listOf types.int; default = []; };
|
||||
};
|
||||
});
|
||||
default = {};
|
||||
description = "Attribute set of docker-compose stacks to run.";
|
||||
};
|
||||
|
||||
config = {
|
||||
# Generate the systemd services based on the options provided above
|
||||
systemd.services = mapAttrs' (name: value: nameValuePair "${name}_stack" {
|
||||
description = "${name} via Docker Compose";
|
||||
after = [ "network-online.target" "docker.service" ];
|
||||
wants = [ "network-online.target" "docker.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
WorkingDirectory = value.path;
|
||||
ExecStartPre = "${pkgs.docker-compose}/bin/docker-compose down";
|
||||
ExecStart = "${pkgs.docker-compose}/bin/docker-compose up -d";
|
||||
ExecStop = "${pkgs.docker-compose}/bin/docker-compose down";
|
||||
RemainAfterExit = true;
|
||||
};
|
||||
}) config.services.myDockerStacks;
|
||||
|
||||
# Automatically open firewall ports
|
||||
networking.firewall.allowedTCPPorts = flatten (mapAttrsToList (n: v: v.ports) config.services.myDockerStacks);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user