Stack/flake.nix
Sobottasgithub 509adad1d6 Initial
2026-01-09 23:15:03 +01:00

54 lines
1.3 KiB
Nix

{
description = "Stack";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ ];
systems =
[ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
perSystem = { config, self', inputs', pkgs, system, ... }:
let
jdk = pkgs.jdk21.override { };
buildInputs = [ jdk ];
devTools = [ pkgs.google-java-format ];
in {
devShells.default =
pkgs.mkShell { buildInputs = buildInputs ++ devTools; };
packages = {
default = pkgs.stdenv.mkDerivation {
pname = "stack";
version = "1.0.0";
src = ./.;
nativeBuildInputs = buildInputs ++ [ pkgs.makeWrapper ];
buildPhase = ''
javac -Werror -g:none -deprecation -verbose Main.java
'';
installPhase = ''
mkdir -p $out/{bin,lib}
cp *.class $out/lib
makeWrapper ${
pkgs.lib.getExe jdk
} $out/bin/stack --add-flags "-cp $out/lib/ Main"
'';
};
};
};
flake = { };
};
}