Clean up Nix configuration and remove old files
- Move Nix package and module to nix/ directory for better organization - Remove old Nix files (systant.nix, systant-old.nix, etc.) - Remove debug script and systemd service file - Update config files for new Nix structure - Add CLAUDE.md with project documentation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.systant;
|
||||
in
|
||||
{
|
||||
options.services.systant = {
|
||||
enable = mkEnableOption "Systant MQTT Daemon";
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
description = "The systant package to use";
|
||||
};
|
||||
|
||||
mqttHost = mkOption {
|
||||
type = types.str;
|
||||
default = "localhost";
|
||||
description = "MQTT broker hostname";
|
||||
};
|
||||
|
||||
mqttPort = mkOption {
|
||||
type = types.int;
|
||||
default = 1883;
|
||||
description = "MQTT broker port";
|
||||
};
|
||||
|
||||
mqttUsername = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = "MQTT username (null for no auth)";
|
||||
};
|
||||
|
||||
mqttPassword = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = "MQTT password (null for no auth)";
|
||||
};
|
||||
|
||||
statsTopic = mkOption {
|
||||
type = types.str;
|
||||
default = "systant/${config.networking.hostName}/stats";
|
||||
description = "MQTT topic for publishing stats";
|
||||
};
|
||||
|
||||
commandTopic = mkOption {
|
||||
type = types.str;
|
||||
default = "systant/${config.networking.hostName}/commands";
|
||||
description = "MQTT topic for receiving commands";
|
||||
};
|
||||
|
||||
publishInterval = mkOption {
|
||||
type = types.int;
|
||||
default = 30000;
|
||||
description = "Interval between stats publications (milliseconds)";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.systant = {
|
||||
description = "Systant MQTT Daemon";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
environment = {
|
||||
SYSTANT_MQTT_HOST = cfg.mqttHost;
|
||||
SYSTANT_MQTT_PORT = toString cfg.mqttPort;
|
||||
SYSTANT_MQTT_USERNAME = mkIf (cfg.mqttUsername != null) cfg.mqttUsername;
|
||||
SYSTANT_MQTT_PASSWORD = mkIf (cfg.mqttPassword != null) cfg.mqttPassword;
|
||||
SYSTANT_STATS_TOPIC = cfg.statsTopic;
|
||||
SYSTANT_COMMAND_TOPIC = cfg.commandTopic;
|
||||
SYSTANT_PUBLISH_INTERVAL = toString cfg.publishInterval;
|
||||
# Override RELEASE_COOKIE to bypass file reading
|
||||
RELEASE_COOKIE = "systant-bypass-cookie";
|
||||
};
|
||||
|
||||
serviceConfig = {
|
||||
Type = "exec";
|
||||
User = "root";
|
||||
Group = "root";
|
||||
ExecStart = "${cfg.package}/bin/systant start";
|
||||
ExecStop = "${cfg.package}/bin/systant stop";
|
||||
Restart = "always";
|
||||
RestartSec = 5;
|
||||
StandardOutput = "journal";
|
||||
StandardError = "journal";
|
||||
SyslogIdentifier = "systant";
|
||||
WorkingDirectory = "${cfg.package}";
|
||||
|
||||
# Security settings
|
||||
NoNewPrivileges = true;
|
||||
PrivateTmp = true;
|
||||
ProtectHome = true;
|
||||
ProtectSystem = false; # Need access to system stats
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
lib,
|
||||
beamPackages,
|
||||
fetchgit,
|
||||
}:
|
||||
|
||||
beamPackages.mixRelease rec {
|
||||
pname = "systant";
|
||||
version = "0.1.0";
|
||||
|
||||
src = fetchgit {
|
||||
url = "https://git.ryanpandya.com/ryan/systant.git";
|
||||
rev = "54f8d23945bcea17127631a81f8ac318bf7047a6";
|
||||
sha256 = "sha256-1cRfSoH+JdO4a7q4hRZSkoDMk2wMCYRIyCIN56FSUgg=";
|
||||
};
|
||||
|
||||
# Mix dependencies will be automatically fetched and cached by Nix
|
||||
mixFodDeps = beamPackages.fetchMixDeps {
|
||||
pname = "systant-mix-deps";
|
||||
inherit src version;
|
||||
sha256 = "sha256-g8L/ZzCaXznrd+YLCMgvV94NVTKoFnK/Y/RXXPIMAjg=";
|
||||
};
|
||||
|
||||
|
||||
meta = with lib; {
|
||||
description = "Systant - System stats MQTT daemon for monitoring system metrics";
|
||||
homepage = "https://git.ryanpandya.com/ryan/systant";
|
||||
license = licenses.mit;
|
||||
maintainers = [ ];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user