[Nix-dev] Tips on deploying a Scala Play application

Teo Klestrup Röijezon teo at nullable.se
Tue Jul 5 22:08:01 CEST 2016


Hi,

A JRE should be enough for running it, but you need sbt and a JDK for
building. I've got a derivation for a Play website at
https://github.com/BlocklandGlass/ParseTS-Playground/blob/master/parsets-playground.nix,
with the NixOS/NixOps setup at
https://github.com/BlocklandGlass/ParseTS-Playground/tree/master/deployment.

The gist of it is to run "sbt stage" in the build phase, and to then take
"target/universal/stage" as your build output. However, you'll also need to
wrap the launcher script to add your JRE and to add gawk (which the
launcher script requires). Finally, on any modern system (such as NixOS)
you'll also want to disable Play's PID file management, since systemd takes
care of that anyway. I didn't in that script, but you'll probably also want
to add a testing phase as part of the build.

The big drawback with this approach is that SBT downloads all dependencies
from the internet on demand, which won't work on a Nix setup with proper
isolation (ideally, builds should only have network access if they
deterministically produce a given hash).

I've been toying with the idea of writing a sbt2nix SBT plugin that
generates Nix definitions to build a local maven mirror for the
dependencies, but I haven't got around to that (yet).

// Teo

On 5 July 2016 at 21:52, 4levels <4levels at gmail.com> wrote:

> Hi Nix-devs,
>
> This is a plain request for assistance / best practices for using Nixos
> with Java / Scala / Play.  Akka with EventSourcing are also a topic of
> interest.
>
> I'm currently trying to get a Scala Play app up and running on my nixOps
> deployed machines.  As I'm very unfamiliar with running Java based apps,
> I'd like to know if someone has experience on the common pitfalls and tips
> on keeping the servers healthy (I just caused my laptop's 8 cores to go
> 100% without being able to stop the server started by the activator call).
>
> I've seen some related packages in nixpkgs and have many questions like
> eg. do I need sbt (which seems to provide typesafe - activator) and a jdk
> on the production servers or are is a jre sufficient? How do I deploy and
> run a Java app developed locally?
> And how do I set-up a local nixos vm for Java development?
>
> I'm still investigating and learning a lot myself, so nix-related
> knowledge is my main concern here (as I need to figure out the rest myself
> anyway ;-)
>
> I'll be happy to share my findings and configuration / setup..
>
>
> Kind regards,
>
> Erik
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160705/cca812f6/attachment.html>


More information about the nix-dev mailing list