Skip to content

Commit db2f758

Browse files
committed
feat: add nix flake build script
1 parent 757273c commit db2f758

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

flake.nix

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
description = "A Scala project with SBT";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = { self, nixpkgs, flake-utils, ... }:
10+
flake-utils.lib.eachDefaultSystem (system:
11+
let
12+
pkgs = import nixpkgs {
13+
inherit system;
14+
};
15+
sbt = pkgs.sbt;
16+
jdk = pkgs.jdk21;
17+
scala = pkgs.scala;
18+
in {
19+
devShell = pkgs.mkShell {
20+
buildInputs = [ sbt jdk scala ];
21+
shellHook = ''
22+
echo "SBT and Scala environment ready!"
23+
'';
24+
};
25+
26+
packages.default = pkgs.stdenv.mkDerivation {
27+
name = "flake-vsys-build-with-sbt";
28+
src = ./.;
29+
buildInputs = [ sbt jdk scala ];
30+
buildPhase = ''
31+
echo "Building with SBT..."
32+
33+
sed -i 's/scalaVersion in ThisBuild := "2.12.6"/scalaVersion in ThisBuild := "2.12.18"/' build.sbt
34+
sed -i 's/sbt.version=1.1.1/sbt.version=1.9.9/' project/build.properties
35+
36+
export HOME=~
37+
38+
sbt packageAll
39+
'';
40+
installPhase = ''
41+
mkdir -p $out
42+
cp -r target $out
43+
'';
44+
};
45+
}
46+
);
47+
}

0 commit comments

Comments
 (0)