1
0

build: add guestbook server build (scala)

This commit is contained in:
dusk 2024-08-23 01:55:30 +03:00
parent b3b53dd1fc
commit c3fcb13b63
Signed by: dusk
SSH Key Fingerprint: SHA256:Abmvag+juovVufZTxyWY8KcVgrznxvBjQpJesv071Aw
2 changed files with 70 additions and 1 deletions

View File

@ -1,5 +1,20 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"naked-shell": {
"locked": {
"lastModified": 1681286841,
@ -66,9 +81,31 @@
"naked-shell": "naked-shell",
"nixpkgs": "nixpkgs",
"parts": "parts",
"sbt-derivation": "sbt-derivation",
"systems": "systems"
}
},
"sbt-derivation": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1698464090,
"narHash": "sha256-Pnej7WZIPomYWg8f/CZ65sfW85IfIUjYhphMMg7/LT0=",
"owner": "zaninime",
"repo": "sbt-derivation",
"rev": "6762cf2c31de50efd9ff905cbcc87239995a4ef9",
"type": "github"
},
"original": {
"owner": "zaninime",
"repo": "sbt-derivation",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1680978846,

View File

@ -3,6 +3,8 @@
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs.systems.url = "github:nix-systems/x86_64-linux";
inputs.naked-shell.url = "github:yusdacra/mk-naked-shell";
inputs.sbt-derivation.url = "github:zaninime/sbt-derivation";
inputs.sbt-derivation.inputs.nixpkgs.follows = "nixpkgs";
outputs = inp:
inp.parts.lib.mkFlake {inputs = inp;} {
@ -12,9 +14,10 @@
];
perSystem = {
config,
pkgs,
system,
...
}: let
pkgs = inp.nixpkgs.legacyPackages.${system}.appendOverlays [inp.sbt-derivation.overlays.default];
packageJson = builtins.fromJSON (builtins.readFile ./package.json);
in {
devShells.default = config.mk-naked-shell.lib.mkNakedShell {
@ -84,6 +87,35 @@
runHook postInstall
'';
};
packages.guestbook-jar = pkgs.mkSbtDerivation rec {
pname = "guestbook";
version = "0.0.1-jar";
depsSha256 = "sha256-hIGZTEZpqgBuo6VGgZ6dQd5kK0RLVNy5REVBBYA3Gak=";
src = ./guestbook;
buildPhase = ''
sbt assembly
mkdir -p ./target/graalvm-native-image
'';
installPhase = ''
mkdir -p $out
cp target/scala-3.4.2/${pname}-assembly-0.0.1-SNAPSHOT.jar $out/${pname}.jar
'';
nativeBuildInputs = [
pkgs.graalvm-ce
];
};
packages.guestbook = pkgs.stdenv.mkDerivation rec {
inherit (config.packages.guestbook-jar) pname nativeBuildInputs;
version = "0.0.1";
src = config.packages.guestbook-jar;
buildPhase = ''
native-image -H:+ReportExceptionStackTraces -H:+AddAllCharsets --allow-incomplete-classpath --no-fallback --initialize-at-run-time --enable-http --enable-all-security-services --verbose -jar "./${pname}.jar" ./${pname}
'';
installPhase = ''
mkdir -p $out/bin
cp ${pname} $out/bin/${pname}
'';
};
packages.default = config.packages.gazesys;
};
};