I'm trying to deploy a VirtualBox with a Play 2 webservice in Scala under NixOS with NixOps.
I have this machine :
{
backoffice = {
deployment.targetEnv = "virtualbox";
deployment.virtualbox.memorySize = 1024; # MB
};
}
On this logical network :
{
network.description = "Test";
backoffice =
{ config, pkgs, ... }:
let
callPackage = pkgs.lib.callPackageWith (pkgs);
Back = callPackage ../pkgs/Backoffice.nix {};
in {
environment.systemPackages = [
pkgs.jdk
Back
];
systemd.services.backoffice = {
description = "Backoffice";
# Start the service after the network is available
after = [ "network.target" ];
script = "${Back}/webapps/bin/play-back";
serviceConfig = {
Restart = "always";
};
};
networking.hostName = "backoffice";
networking.firewall.allowedTCPPorts = [ 80 ];
system.stateVersion = "15.09";
};
}
Where Backoffice.nix is this derivation :
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "Backoffice";
src = ../../back;
buildInputs = [ sbt ];
buildPhase = let
sbtBootDir = "./.sbt/boot/";
sbtIvyHome = "/var/tmp/`whoami`/.ivy";
sbtOpts = "-XX:PermSize=190m -Dsbt.boot.directory=${sbtBootDir} -Dsbt.ivy.home=${sbtIvyHome}";
in ''
mkdir -p ${sbtBootDir}
mkdir -p ${sbtIvyHome}
sbt ${sbtOpts} stage
'';
installPhase = ''
mkdir -p $out/webapps
cp -ra ./target/universal/stage/* $out
'';
}
The VM starts and deploys fine. But when I ssh into it I can't find my Backoffice derivation inside.
If I do locally
nix-build Backoffice.nix
...it builds without problems, and I can find the derivation in /nix/store on my dev machine.
In the VM, there is a /nix/store/shaXXX-backoffice.service, so it kind of works. But since the backoffice derivation is not present, it does nothing.
Can someone tell me what I'm doing wrong?
Found it! What was needed in systemd.services.backoffice :
path = [ "${pkgs.jdk.home}" "${pkgs.gawk}" ];
Play Framework script is using both to start itself.