Skip to content

Commit

Permalink
flake: add run-stack helper
Browse files Browse the repository at this point in the history
  • Loading branch information
marijanp committed Sep 6, 2024
1 parent 3c099e7 commit 4bed509
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,45 @@
};

packages = {
run-stack = pkgs.writeShellApplication {
name = "run-stack";
runtimeInputs = [
pkgs.tinyproxy
pkgs.simple-http-server
];
text =
let
proxyConfig = pkgs.writeTextFile {
name = "proxy.conf";
text = ''
ReversePath "/" "http://0.0.0.0:8001/"
ReversePath "/api/" "http://0.0.0.0:8002/api/"
ReverseOnly Yes
Port 8000
ReverseBaseURL "http://0.0.0.0:8000/"
'';
};
in
''
simple-http-server --index --port 8001 frontend &
PID_FRONTEND=$!
cargo run -- --listen-address 0.0.0.0:8002 &
PID_BACKEND=$!
tinyproxy -d -c ${proxyConfig} &
PID_PROXY=$!
cleanup() {
kill $PID_FRONTEND $PID_BACKEND $PID_PROXY
wait $PID_FRONTEND $PID_BACKEND $PID_PROXY
exit 0
}
trap cleanup SIGINT
wait $PID_FRONTEND $PID_BACKEND $PID_PROXY
'';
};

server-deps = craneLib.buildDepsOnly commonAttrs;

server-docs = craneLib.cargoDoc (
Expand Down

0 comments on commit 4bed509

Please sign in to comment.