111 lines
3.1 KiB
Nix
111 lines
3.1 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.naxos.appEngine;
|
|
in {
|
|
options.services.naxos.appEngine = {
|
|
enable = mkEnableOption "NaxOS Multi-Tier App Engine";
|
|
|
|
defaultRuntime = mkOption {
|
|
type = types.enum [ "systemd" "docker" "k3s" ];
|
|
default = "docker";
|
|
description = "Default execution runtime for user workloads.";
|
|
};
|
|
|
|
docker = {
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = true;
|
|
description = "Enable Docker engine for containerized applications.";
|
|
};
|
|
storageDriver = mkOption {
|
|
type = types.enum [ "zfs" "overlay2" "btrfs" ];
|
|
default = "zfs";
|
|
description = "Container storage driver. 'zfs' uses native copy-on-write datasets.";
|
|
};
|
|
dataRoot = mkOption {
|
|
type = types.str;
|
|
default = "/var/lib/docker";
|
|
description = "Storage root for container images and layers.";
|
|
};
|
|
};
|
|
|
|
k3s = {
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = "Enable lightweight K3s single-node cluster for cloud-native orchestration.";
|
|
};
|
|
role = mkOption {
|
|
type = types.enum [ "server" "agent" ];
|
|
default = "server";
|
|
description = "K3s node role.";
|
|
};
|
|
tokenFile = mkOption {
|
|
type = types.nullOr types.str;
|
|
default = null;
|
|
description = "Path to token file for K3s node join / cluster security.";
|
|
};
|
|
};
|
|
|
|
gpuAcceleration = {
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = true;
|
|
description = "Enable hardware transcoding and machine learning acceleration.";
|
|
};
|
|
vendor = mkOption {
|
|
type = types.enum [ "intel" "nvidia" "amd" "none" ];
|
|
default = "intel";
|
|
description = "Primary GPU hardware vendor.";
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
# 1. Docker Runtime Configuration
|
|
virtualisation.docker = mkIf cfg.docker.enable {
|
|
enable = true;
|
|
storageDriver = cfg.docker.storageDriver;
|
|
daemon.settings = {
|
|
data-root = cfg.docker.dataRoot;
|
|
log-driver = "journald";
|
|
};
|
|
};
|
|
|
|
# OCI container backend compatibility
|
|
virtualisation.oci-containers.backend = mkIf cfg.docker.enable "docker";
|
|
|
|
# 2. K3s Runtime Configuration
|
|
services.k3s = mkIf cfg.k3s.enable {
|
|
enable = true;
|
|
role = cfg.k3s.role;
|
|
tokenFile = cfg.k3s.tokenFile;
|
|
extraFlags = toString [
|
|
"--disable=traefik" # We manage ingress/reverse-proxy through NaxOS
|
|
"--snapshotter=native"
|
|
];
|
|
};
|
|
|
|
# 3. Hardware Graphics Acceleration
|
|
hardware.graphics = mkIf cfg.gpuAcceleration.enable {
|
|
enable = true;
|
|
extraPackages = mkIf (cfg.gpuAcceleration.vendor == "intel") (with pkgs; [
|
|
intel-media-driver # Broadwell or newer
|
|
intel-compute-runtime # OpenCL support
|
|
vpl-gpu-rt # QSV support (11th Gen+)
|
|
]);
|
|
};
|
|
|
|
# 4. System packages for workload operations
|
|
environment.systemPackages = with pkgs; [
|
|
docker-compose
|
|
lazydocker
|
|
kubectl
|
|
dive
|
|
];
|
|
};
|
|
}
|