- Add creditservice.nix module for credit service deployment - Update default.nix to import creditservice module - Required for T039.S3 NixOS provisioning 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
76 lines
2 KiB
Nix
76 lines
2 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
cfg = config.services.creditservice;
|
|
in
|
|
{
|
|
options.services.creditservice = {
|
|
enable = lib.mkEnableOption "creditservice service";
|
|
|
|
port = lib.mkOption {
|
|
type = lib.types.port;
|
|
default = 3010;
|
|
description = "Port for creditservice gRPC API";
|
|
};
|
|
|
|
dataDir = lib.mkOption {
|
|
type = lib.types.path;
|
|
default = "/var/lib/creditservice";
|
|
description = "Data directory for creditservice";
|
|
};
|
|
|
|
settings = lib.mkOption {
|
|
type = lib.types.attrs;
|
|
default = {};
|
|
description = "Additional configuration settings";
|
|
};
|
|
|
|
package = lib.mkOption {
|
|
type = lib.types.package;
|
|
default = pkgs.creditservice-server or (throw "creditservice-server package not found");
|
|
description = "Package to use for creditservice";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
# Create system user
|
|
users.users.creditservice = {
|
|
isSystemUser = true;
|
|
group = "creditservice";
|
|
description = "CreditService quota/billing user";
|
|
home = cfg.dataDir;
|
|
};
|
|
|
|
users.groups.creditservice = {};
|
|
|
|
# Create systemd service
|
|
systemd.services.creditservice = {
|
|
description = "CreditService Quota and Billing Management";
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [ "network.target" "chainfire.service" "nightlight.service" ];
|
|
wants = [ "chainfire.service" "nightlight.service" ];
|
|
|
|
serviceConfig = {
|
|
Type = "simple";
|
|
User = "creditservice";
|
|
Group = "creditservice";
|
|
Restart = "on-failure";
|
|
RestartSec = "10s";
|
|
|
|
# State directory management
|
|
StateDirectory = "creditservice";
|
|
StateDirectoryMode = "0750";
|
|
|
|
# Security hardening
|
|
NoNewPrivileges = true;
|
|
PrivateTmp = true;
|
|
ProtectSystem = "strict";
|
|
ProtectHome = true;
|
|
ReadWritePaths = [ cfg.dataDir ];
|
|
|
|
# Start command
|
|
ExecStart = "${cfg.package}/bin/creditservice-server --port ${toString cfg.port} --data-dir ${cfg.dataDir}";
|
|
};
|
|
};
|
|
};
|
|
}
|