feat(nix): Add creditservice module for NixOS deployment
- 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>
This commit is contained in:
parent
bbc7282b33
commit
4547dacc7e
2 changed files with 77 additions and 0 deletions
76
nix/modules/creditservice.nix
Normal file
76
nix/modules/creditservice.nix
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
{ 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}";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
imports = [
|
||||
./chainfire.nix
|
||||
./creditservice.nix
|
||||
./flaredb.nix
|
||||
./iam.nix
|
||||
./plasmavmc.nix
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue