我尝试使用NixOS在NixOS下使用Scala中的Play 2 Web服务部署VirtualBox。
我有这台机器:
{
backoffice = {
deployment.targetEnv = "virtualbox";
deployment.virtualbox.memorySize = 1024; # MB
};
}
在这个逻辑网络上:
{
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";
};
}
Backoffice.nix是这个派生的地方:
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
'';
}
VM启动并部署正常。但是当我进入它时,我无法在里面找到我的后台派生。
如果我在当地做
nix-build Backoffice.nix
...它构建没有问题,我可以在我的开发机器上的/ nix / store中找到派生。
在VM中,有一个/nix/store/shaXXX-backoffice.service,所以它有点工作。但由于后台派生不存在,它什么都不做。
有人能告诉我我做错了吗?
答案 0 :(得分:2)
path = [ "${pkgs.jdk.home}" "${pkgs.gawk}" ];
Play Framework脚本正在使用它们来启动它自己。