feat(11): initial module with a service
This commit is contained in:
parent
e7594ef2eb
commit
73bd2eba84
|
@ -12,3 +12,4 @@
|
||||||
*/target/
|
*/target/
|
||||||
|
|
||||||
*/result
|
*/result
|
||||||
|
result
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ pkgs, sbt-derivation }:
|
{ pkgs, lib, sbt-derivation }:
|
||||||
|
|
||||||
let
|
let
|
||||||
package = sbt-derivation.lib.mkSbtDerivation {
|
package = sbt-derivation.lib.mkSbtDerivation {
|
||||||
|
@ -17,7 +17,7 @@ let
|
||||||
# anyway copied to correct place
|
# anyway copied to correct place
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cp target/scala-*/priceGrid-assembly-*.jar $out/bin/
|
cp target/scala-*/priceGrid-assembly-*.jar $out/bin/priceGridApp.jar
|
||||||
mkdir -p $out/bin/dist
|
mkdir -p $out/bin/dist
|
||||||
cp ./output.css $out/bin/dist/output.css
|
cp ./output.css $out/bin/dist/output.css
|
||||||
cp -r public $out/bin/public
|
cp -r public $out/bin/public
|
||||||
|
@ -26,14 +26,47 @@ let
|
||||||
depsSha256 = "sha256-aWLqnPXvchtNqpSfXo5sWyK2QFNn1GqToy58cWrML3U=";
|
depsSha256 = "sha256-aWLqnPXvchtNqpSfXo5sWyK2QFNn1GqToy58cWrML3U=";
|
||||||
};
|
};
|
||||||
|
|
||||||
module = { config, pkgs, ... }: {
|
module = { config, pkgs, ... }:
|
||||||
services.price-grid-app = {
|
let cfg = config.services.priceGridService;
|
||||||
enable = true;
|
in {
|
||||||
package = package;
|
options.services.priceGridService = {
|
||||||
|
enable = lib.mkEnableOption "My service";
|
||||||
|
|
||||||
|
port = lib.mkOption {
|
||||||
|
type = lib.types.int;
|
||||||
|
default = 8080;
|
||||||
|
description = "Port to listen on.";
|
||||||
|
};
|
||||||
|
|
||||||
|
host = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "localhost";
|
||||||
|
description = "Host to bind to.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
config = lib.mkIf cfg.enable {
|
||||||
{
|
users.groups.price-grid-app-group = { };
|
||||||
|
users.users.price-grid-app-user = {
|
||||||
|
isSystemUser = true;
|
||||||
|
group = "price-grid-app-group";
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services.price-grid-app = {
|
||||||
|
description = "My Java Service";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
after = [ "network.target" ];
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
ExecStart =
|
||||||
|
"${pkgs.jdk}/bin/java -jar ${package}/bin/priceGridApp.jar -p ${toString cfg.port} --host ${cfg.host}";
|
||||||
|
Restart = "on-failure";
|
||||||
|
User = "price-grid-app-user";
|
||||||
|
Group = "price-grid-app-group";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in {
|
||||||
package = package;
|
package = package;
|
||||||
module = module;
|
module = module;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
price-grid = import ./11-single-price-grid-component/default.nix {
|
price-grid = import ./11-single-price-grid-component/default.nix {
|
||||||
inherit pkgs sbt-derivation;
|
inherit pkgs sbt-derivation;
|
||||||
|
lib = pkgs.lib;
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
|
|
Loading…
Reference in New Issue