Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@
};

# Function to add logging logic to any command
withLogging = command: logFile: "mkdir -p ${config.devenv.root}/logs && bash -c 'stdbuf -oL ${command} 2>&1 | tee -a ${config.devenv.root}/logs/${logFile}'";
withLogging = command: logFile: ''
mkdir -p ${config.devenv.root}/logs
${command} 2>&1 | stdbuf -oL tee -a ${config.devenv.root}/logs/${logFile}
'';

# Get all process names dynamically
processNames = lib.attrNames config.processes;
in {
env.BITCOIND_DATADIR = config.devenv.root + "/.devenv/state/bitcoind";
env.REDIS_HOST = "localhost";
env.REDIS_PORT = "6379";

# Ensure logs directory exists before processes run
tasks.create-logs-dir = {
Expand All @@ -31,6 +36,7 @@ in {
bitcoind
pkgs.just
pkgs.coreutils # Provides stdbuf for disabling output buffering
pkgs.redis
]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [pkgs.darwin.apple_sdk.frameworks.Security];

Expand All @@ -42,6 +48,7 @@ in {

# https://devenv.sh/processes/
processes = {
redis = {exec = withLogging "mkdir -p ${config.devenv.root}/.devenv/state/redis && redis-server --dir ${config.devenv.root}/.devenv/state/redis --port $REDIS_PORT" "redis.log";};
local-pool = {exec = withLogging "cargo -C roles/pool -Z unstable-options run -- -c $DEVENV_ROOT/roles/pool/config-examples/pool-config-local-tp-example.toml" "local-pool.log";};
job-server = {exec = withLogging "cargo -C roles/jd-server -Z unstable-options run -- -c $DEVENV_ROOT/roles/jd-server/config-examples/jds-config-local-example.toml" "job-server.log";};
job-client = {exec = withLogging "cargo -C roles/jd-client -Z unstable-options run -- -c $DEVENV_ROOT/roles/jd-client/config-examples/jdc-config-local-example.toml" "job-client.log";};
Expand Down
Loading