A toy web server written in Scala using http4s
The point of this project is to demonstrate how scala-cli and nix flakes can be leveraged to build and distribute Scala apps in 4 different ways:
- as a standalone jar running on the JVM;
- as a native executable compiled by Scala Native;
- as a GraalVM native image;
- as a Node.js app compiled by Scala.js.
If you have nix installed and flakes enabled:
nix run github:buntec/minimal-scala-native-http4s-server-app#jvm --refresh
nix run github:buntec/minimal-scala-native-http4s-server-app#native --refresh
nix run github:buntec/minimal-scala-native-http4s-server-app#graal --refresh
nix run github:buntec/minimal-scala-native-http4s-server-app#node --refresh
Note that running any of the above will be slow the first time only - after the initial build everything is cached in your nix store.
If you want the actual binary, simply replace run
by build
.
This flake also contains a dev shell suitable for working on the app:
nix develop github:buntec/minimal-scala-native-http4s-server-app --refresh
The --refresh
flag above ensures that you always get the most recent commit.