diff --git a/debug-nix-store.sh b/debug-nix-store.sh new file mode 100644 index 0000000..c4e69d9 --- /dev/null +++ b/debug-nix-store.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Debug script to check what's in the Nix store +STORE_PATH="/nix/store/i3fa1p0y8mcyljzfsj6k65qfpmd4yyaf-systant-0.1.0" + +echo "=== Checking Nix store contents ===" +echo "Store path: $STORE_PATH" +echo + +echo "=== Top level contents ===" +ls -la "$STORE_PATH/" +echo + +echo "=== Looking for COOKIE files ===" +find "$STORE_PATH" -name "*COOKIE*" -o -name "*cookie*" 2>/dev/null || echo "No COOKIE files found" +echo + +echo "=== releases directory ===" +if [ -d "$STORE_PATH/releases" ]; then + ls -la "$STORE_PATH/releases/" +else + echo "No releases directory found" +fi +echo + +echo "=== bin directory ===" +if [ -d "$STORE_PATH/bin" ]; then + ls -la "$STORE_PATH/bin/" +else + echo "No bin directory found" +fi +echo + +echo "=== Checking startup script ===" +if [ -f "$STORE_PATH/bin/systant" ]; then + echo "Startup script exists, checking for COOKIE references:" + grep -n "COOKIE" "$STORE_PATH/bin/systant" || echo "No COOKIE references in startup script" +else + echo "No startup script found" +fi \ No newline at end of file diff --git a/mix.exs b/mix.exs index b0b3284..250461b 100644 --- a/mix.exs +++ b/mix.exs @@ -33,7 +33,6 @@ defmodule SystemStatsDaemon.MixProject do systant: [ include_executables_for: [:unix], applications: [runtime_tools: :permanent], - cookie: "systant-cookie-change-in-production", include_erts: true, strip_beams: false ] diff --git a/rel/env.sh.eex b/rel/env.sh.eex index a5fce74..273f7f9 100644 --- a/rel/env.sh.eex +++ b/rel/env.sh.eex @@ -2,4 +2,5 @@ # Configure environment for release export MIX_ENV=prod -export RELEASE_DISTRIBUTION=none \ No newline at end of file +export RELEASE_DISTRIBUTION=none +export RELEASE_NODE=nonode@nohost \ No newline at end of file diff --git a/systant-manual.nix b/systant-manual.nix new file mode 100644 index 0000000..0b316b8 --- /dev/null +++ b/systant-manual.nix @@ -0,0 +1,62 @@ +{ lib, stdenv, fetchgit, elixir, erlang, rebar3, git }: + +stdenv.mkDerivation rec { + pname = "systant"; + version = "0.1.0"; + + src = fetchgit { + url = "https://git.ryanpandya.com/ryan/systant.git"; + rev = "f8173a1afb03623039ff504c587d7322a9876f3d"; + sha256 = "sha256-1cRfSoH+JdO4a7q4hRZSkoDMk2wMCYRIyCIN56FSUgg="; + }; + + nativeBuildInputs = [ elixir erlang rebar3 git ]; + + # Disable network access - we'll handle deps manually + MIX_ENV = "prod"; + + configurePhase = '' + export MIX_HOME=$TMPDIR/mix + export HEX_HOME=$TMPDIR/hex + export REBAR_CACHE_DIR=$TMPDIR/rebar3 + + # Install hex and rebar locally + mix local.hex --force + mix local.rebar --force + ''; + + buildPhase = '' + # This will fail but that's OK - we're using it to get deps info + mix deps.get || true + + # Manual dependency installation (you'd need to add each dep here) + # For now, let's try without deps to see if it builds + mix deps.compile --skip-deps || true + mix compile + mix release + + echo "=== Build phase debug ===" + find _build/prod/rel/ -name "*COOKIE*" || echo "No COOKIE in build" + ''; + + installPhase = '' + mkdir -p $out + cp -r _build/prod/rel/systant/* $out/ + + # Force create COOKIE file + mkdir -p $out/releases + echo "systant-cookie-change-in-production" > $out/releases/COOKIE + + echo "=== Install phase debug ===" + echo "COOKIE created manually in installPhase" > /tmp/manual-nix-debug + ls -la $out/releases/ + cat $out/releases/COOKIE + ''; + + meta = with lib; { + description = "Systant - System stats MQTT daemon"; + homepage = "https://git.ryanpandya.com/ryan/systant"; + license = licenses.mit; + platforms = platforms.linux; + }; +} \ No newline at end of file diff --git a/systant-wrapper.nix b/systant-wrapper.nix new file mode 100644 index 0000000..c9003a9 --- /dev/null +++ b/systant-wrapper.nix @@ -0,0 +1,67 @@ +{ lib, stdenv, fetchgit, elixir, erlang, rebar3, git, writeShellScript }: + +let + systantBase = stdenv.mkDerivation rec { + pname = "systant-base"; + version = "0.1.0"; + + src = fetchgit { + url = "https://git.ryanpandya.com/ryan/systant.git"; + rev = "f8173a1afb03623039ff504c587d7322a9876f3d"; + sha256 = "sha256-1cRfSoH+JdO4a7q4hRZSkoDMk2wMCYRIyCIN56FSUgg="; + }; + + nativeBuildInputs = [ elixir erlang rebar3 git ]; + + MIX_ENV = "prod"; + + configurePhase = '' + export MIX_HOME=$TMPDIR/mix + export HEX_HOME=$TMPDIR/hex + export REBAR_CACHE_DIR=$TMPDIR/rebar3 + + mix local.hex --force + mix local.rebar --force + ''; + + buildPhase = '' + mix deps.get || true + mix deps.compile || true + mix compile + mix release + ''; + + installPhase = '' + mkdir -p $out + cp -r _build/prod/rel/systant/* $out/ + ''; + }; + + systantWrapper = writeShellScript "systant" '' + #!/bin/bash + export RELEASE_COOKIE="systant-cookie-change-in-production" + exec ${systantBase}/bin/systant "$@" + ''; + +in stdenv.mkDerivation { + pname = "systant"; + version = "0.1.0"; + + buildCommand = '' + mkdir -p $out/bin + cp ${systantWrapper} $out/bin/systant + chmod +x $out/bin/systant + + # Copy the rest of the release + cp -r ${systantBase}/* $out/ + + echo "Wrapper created - RELEASE_COOKIE will be set by wrapper script" + ''; + + meta = with lib; { + description = "Systant - System stats MQTT daemon"; + homepage = "https://git.ryanpandya.com/ryan/systant"; + license = licenses.mit; + platforms = platforms.linux; + }; +} \ No newline at end of file diff --git a/systant.nix b/systant.nix index de402c2..118bd48 100644 --- a/systant.nix +++ b/systant.nix @@ -1,4 +1,8 @@ -{ lib, beamPackages, fetchgit }: +{ + lib, + beamPackages, + fetchgit, +}: beamPackages.mixRelease rec { pname = "systant"; @@ -6,24 +10,17 @@ beamPackages.mixRelease rec { src = fetchgit { url = "https://git.ryanpandya.com/ryan/systant.git"; - rev = "9d8ad1890b682a58aaa27406a7f28337c4c67d5f"; - sha256 = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; + rev = "f8173a1afb03623039ff504c587d7322a9876f3d"; + 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-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; + sha256 = "sha256-g8L/ZzCaXznrd+YLCMgvV94NVTKoFnK/Y/RXXPIMAjg="; }; - # Ensure COOKIE file exists - postInstall = '' - if [ ! -f $out/releases/COOKIE ]; then - mkdir -p $out/releases - echo "systant-cookie-change-in-production" > $out/releases/COOKIE - fi - ''; meta = with lib; { description = "Systant - System stats MQTT daemon for monitoring system metrics"; @@ -32,4 +29,4 @@ beamPackages.mixRelease rec { maintainers = [ ]; platforms = platforms.linux; }; -} \ No newline at end of file +}