photoncloud-monorepo/nix/modules/k8shost.nix
centra 5c6eb04a46 T036: Add VM cluster deployment configs for nixos-anywhere
- netboot-base.nix with SSH key auth
- Launch scripts for node01/02/03
- Node configuration.nix and disko.nix
- Nix modules for first-boot automation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-11 09:59:19 +09:00

76 lines
2 KiB
Nix

{ config, lib, pkgs, ... }:
let
cfg = config.services.k8shost;
in
{
options.services.k8shost = {
enable = lib.mkEnableOption "k8shost service";
port = lib.mkOption {
type = lib.types.port;
default = 6443;
description = "Port for k8shost API server";
};
dataDir = lib.mkOption {
type = lib.types.path;
default = "/var/lib/k8shost";
description = "Data directory for k8shost";
};
settings = lib.mkOption {
type = lib.types.attrs;
default = {};
description = "Additional configuration settings";
};
package = lib.mkOption {
type = lib.types.package;
default = pkgs.k8shost-server or (throw "k8shost-server package not found");
description = "Package to use for k8shost";
};
};
config = lib.mkIf cfg.enable {
# Create system user
users.users.k8shost = {
isSystemUser = true;
group = "k8shost";
description = "K8shost Kubernetes Hosting Service user";
home = cfg.dataDir;
};
users.groups.k8shost = {};
# Create systemd service
systemd.services.k8shost = {
description = "K8shost Kubernetes Hosting Service";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" "iam.service" "flaredb.service" "novanet.service" ];
requires = [ "iam.service" "flaredb.service" "novanet.service" ];
serviceConfig = {
Type = "simple";
User = "k8shost";
Group = "k8shost";
Restart = "on-failure";
RestartSec = "10s";
# State directory management
StateDirectory = "k8shost";
StateDirectoryMode = "0750";
# Security hardening
NoNewPrivileges = true;
PrivateTmp = true;
ProtectSystem = "strict";
ProtectHome = true;
ReadWritePaths = [ cfg.dataDir ];
# Start command
ExecStart = "${cfg.package}/bin/k8shost-server --port ${toString cfg.port} --data-dir ${cfg.dataDir}";
};
};
};
}