Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nix flake build script #322

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
description = "A Scala project with SBT";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
sbt = pkgs.sbt;
jdk = pkgs.jdk21;
scala = pkgs.scala;
in {
devShell = pkgs.mkShell {
buildInputs = [ sbt jdk scala ];
shellHook = ''
echo "SBT and Scala environment ready!"
'';
};

packages.default = pkgs.stdenv.mkDerivation {
name = "flake-vsys-build-with-sbt";
src = ./.;
buildInputs = [ sbt jdk scala ];
buildPhase = ''
echo "Building with SBT..."

sed -i 's/scalaVersion in ThisBuild := "2.12.6"/scalaVersion in ThisBuild := "2.12.18"/' build.sbt
sed -i 's/sbt.version=1.1.1/sbt.version=1.9.9/' project/build.properties

export HOME=~

sbt packageAll
'';
installPhase = ''
mkdir -p $out
cp -r target $out
'';
};
}
);
}
Loading