photoncloud-monorepo/nix/modules/lightningstor.nix
centra baa3e038f9 Add NixOS service modules to git tracking
The nix/modules directory was untracked, causing flake evaluation to fail
when referencing ./nix/modules. This adds 9 service module definitions
created during T024 NixOS packaging.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-09 17:34:41 +09:00

76 lines
2 KiB
Nix

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