Fix Elixir release configuration
- Add explicit cookie to release config to fix missing COOKIE file - Add config/runtime.exs for environment-based configuration - Release now supports runtime environment variables - Binary starts successfully without COOKIE errors Environment variables supported: - SYSTANT_MQTT_HOST, SYSTANT_MQTT_PORT - SYSTANT_MQTT_USERNAME, SYSTANT_MQTT_PASSWORD - SYSTANT_STATS_TOPIC, SYSTANT_COMMAND_TOPIC - SYSTANT_PUBLISH_INTERVAL 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
92fc90e3b4
commit
9d8ad1890b
12
config/runtime.exs
Normal file
12
config/runtime.exs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import Config
|
||||||
|
|
||||||
|
# Runtime configuration that can use environment variables
|
||||||
|
config :systant, Systant.MqttClient,
|
||||||
|
host: System.get_env("SYSTANT_MQTT_HOST", "localhost"),
|
||||||
|
port: String.to_integer(System.get_env("SYSTANT_MQTT_PORT", "1883")),
|
||||||
|
client_id: System.get_env("SYSTANT_CLIENT_ID", "systant"),
|
||||||
|
username: System.get_env("SYSTANT_MQTT_USERNAME"),
|
||||||
|
password: System.get_env("SYSTANT_MQTT_PASSWORD"),
|
||||||
|
stats_topic: System.get_env("SYSTANT_STATS_TOPIC", "system/stats"),
|
||||||
|
command_topic: System.get_env("SYSTANT_COMMAND_TOPIC", "system/commands"),
|
||||||
|
publish_interval: String.to_integer(System.get_env("SYSTANT_PUBLISH_INTERVAL", "30000"))
|
||||||
3
mix.exs
3
mix.exs
@ -32,7 +32,8 @@ defmodule SystemStatsDaemon.MixProject do
|
|||||||
[
|
[
|
||||||
systant: [
|
systant: [
|
||||||
include_executables_for: [:unix],
|
include_executables_for: [:unix],
|
||||||
applications: [runtime_tools: :permanent]
|
applications: [runtime_tools: :permanent],
|
||||||
|
cookie: "systant-cookie-change-in-production"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|||||||
73
systant-old.nix
Normal file
73
systant-old.nix
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
{ lib
|
||||||
|
, stdenv
|
||||||
|
, fetchgit
|
||||||
|
, elixir
|
||||||
|
, erlang
|
||||||
|
, rebar3
|
||||||
|
, git
|
||||||
|
, cacert
|
||||||
|
, glibcLocales
|
||||||
|
}:
|
||||||
|
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
pname = "systant";
|
||||||
|
version = "0.1.0";
|
||||||
|
|
||||||
|
src = fetchgit {
|
||||||
|
url = "https://git.ryanpandya.com/ryan/systant.git";
|
||||||
|
rev = "92fc90e3b470dd2d11ba3a84745e33195e8e9db3";
|
||||||
|
sha256 = lib.fakeSha256; # Replace with actual hash after first build attempt
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
elixir
|
||||||
|
erlang
|
||||||
|
rebar3
|
||||||
|
git
|
||||||
|
cacert
|
||||||
|
glibcLocales
|
||||||
|
];
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
|
# Set up environment for Mix/Hex
|
||||||
|
export MIX_ENV=prod
|
||||||
|
export MIX_HOME=$TMPDIR/mix
|
||||||
|
export HEX_HOME=$TMPDIR/hex
|
||||||
|
export REBAR_CACHE_DIR=$TMPDIR/rebar3
|
||||||
|
|
||||||
|
# SSL and locale configuration
|
||||||
|
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
|
||||||
|
export LOCALE_ARCHIVE=${glibcLocales}/lib/locale/locale-archive
|
||||||
|
export LC_ALL=en_US.UTF-8
|
||||||
|
export ELIXIR_ERL_OPTIONS="+fnu"
|
||||||
|
|
||||||
|
# Install hex and rebar locally
|
||||||
|
mix local.hex --force
|
||||||
|
mix local.rebar --force
|
||||||
|
|
||||||
|
# Get dependencies and build release
|
||||||
|
mix deps.get --only=prod
|
||||||
|
mix release
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
mkdir -p $out
|
||||||
|
cp -r _build/prod/rel/systant/* $out/
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "Systant - System stats MQTT daemon for monitoring system metrics";
|
||||||
|
homepage = "https://git.ryanpandya.com/ryan/systant";
|
||||||
|
license = licenses.mit; # Update if different
|
||||||
|
maintainers = [ ]; # Add your maintainer info if desired
|
||||||
|
platforms = platforms.linux;
|
||||||
|
};
|
||||||
|
}
|
||||||
54
systant.nix
54
systant.nix
@ -1,59 +1,27 @@
|
|||||||
{ lib
|
{ lib, beamPackages, fetchgit }:
|
||||||
, stdenv
|
|
||||||
, fetchgit
|
|
||||||
, elixir
|
|
||||||
, erlang
|
|
||||||
, rebar3
|
|
||||||
, git
|
|
||||||
}:
|
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
beamPackages.mixRelease rec {
|
||||||
pname = "systant";
|
pname = "systant";
|
||||||
version = "0.1.0";
|
version = "0.1.0";
|
||||||
|
|
||||||
src = fetchgit {
|
src = fetchgit {
|
||||||
url = "https://git.ryanpandya.com/ryan/systant.git";
|
url = "https://git.ryanpandya.com/ryan/systant.git";
|
||||||
rev = "9d8306a64b7893ea0d25e2b08f470541fb4db7c8";
|
rev = "92fc90e3b470dd2d11ba3a84745e33195e8e9db3";
|
||||||
sha256 = lib.fakeSha256; # Replace with actual hash after first build attempt
|
sha256 = lib.fakeSha256; # Replace with actual hash after first build attempt
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [
|
# Mix dependencies will be automatically fetched and cached by Nix
|
||||||
elixir
|
mixFodDeps = beamPackages.fetchMixDeps {
|
||||||
erlang
|
pname = "systant-mix-deps";
|
||||||
rebar3
|
inherit src version;
|
||||||
git
|
sha256 = lib.fakeSha256; # Will get this from first build failure
|
||||||
];
|
};
|
||||||
|
|
||||||
buildPhase = ''
|
|
||||||
runHook preBuild
|
|
||||||
|
|
||||||
export MIX_ENV=prod
|
|
||||||
export MIX_HOME=$TMPDIR/mix
|
|
||||||
export HEX_HOME=$TMPDIR/hex
|
|
||||||
export REBAR_CACHE_DIR=$TMPDIR/rebar3
|
|
||||||
|
|
||||||
mix local.hex --force
|
|
||||||
mix local.rebar --force
|
|
||||||
mix deps.get --only=prod
|
|
||||||
mix release
|
|
||||||
|
|
||||||
runHook postBuild
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
runHook preInstall
|
|
||||||
|
|
||||||
mkdir -p $out
|
|
||||||
cp -r _build/prod/rel/systant/* $out/
|
|
||||||
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "Systant - System stats MQTT daemon for monitoring system metrics";
|
description = "Systant - System stats MQTT daemon for monitoring system metrics";
|
||||||
homepage = "https://git.ryanpandya.com/ryan/systant";
|
homepage = "https://git.ryanpandya.com/ryan/systant";
|
||||||
license = licenses.mit; # Update if different
|
license = licenses.mit;
|
||||||
maintainers = [ ]; # Add your maintainer info if desired
|
maintainers = [ ];
|
||||||
platforms = platforms.linux;
|
platforms = platforms.linux;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user