feat: initial version of the full setup

This commit is contained in:
Xavier Morel
2025-10-23 19:36:05 +02:00
commit cc957061de
12 changed files with 841 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
{ pkgs, containersMapping, ... }:
let
infra = import ../infra/constants.nix;
in
{
# OPTIONAL int cores: number of CPU (default = 1)
cores = 2;
# OPTIONAL int memory: RAM memory (default 512)
memory = 512;
# OPTIONAL string disk: disk space (default "4G") - beware, NixOS is greedy
disk = "4G";
# OPTIONAL string swap: swap space (default null)
swap = null;
# OPTIONAL list of int ports: ports to open (TCP tho) (default [])
ports = [ 80 ];
# OPTIONAL submodule services: services to be passed to the NixOS Module (default {})
services = {
nginx.enable = true;
};
# OPTIONAL list of pkgs other_packages: packages to add to eenvironment.systemPackages (default [])
other_packages = [ pkgs.hello ];
# OPTIONAL submodule etc: files contents to pass to eenvironment.etc
etc."alloy/log-myservice.alloy" = ''
# logger_ip = ${infra.build_ip containersMapping.grafana}
# prometheus = ${infra.build_ip containersMapping.prometheus}
'';
# OPTIONAL bool logging.enable: whether to enable the Alloy configuration (=> Loki)
# Need further configuration in etc."alloy/log-myservice.alloy"
logging.enable = true;
# OPTIONAL bool logging.metrics.enable: whether to enable the Alloy metrics configuration (=> Prometheus)
logging.metrics.enable = true;
}

36
lxc/default.nix Normal file
View File

@@ -0,0 +1,36 @@
{ pkgs, containersMapping, ... }:
let
lib = pkgs.lib;
containerBuild = import ../lib/containers.nix;
containersFiles = builtins.readDir ./.;
containers = lib.filterAttrs (_: v: v != null) (
lib.mapAttrs (
name: type:
if type == "regular" && name != "default.nix" && lib.hasSuffix ".nix" name then
import ./${name} { inherit containersMapping pkgs; }
else
null
) containersFiles
);
cleanedName = lib.listToAttrs (lib.mapAttrsToList (name: def: mkContainer name def) containers);
mkContainer =
name: raw_def:
let
hostname = lib.removeSuffix ".nix" name;
def = raw_def // {
hostname = hostname;
container_id = containersMapping.${hostname};
};
result = containerBuild { inherit def; };
in
{
name = hostname;
value = result;
};
in
cleanedName