dev-templates/java/flake.nix
2022-07-29 01:34:22 +02:00

36 lines
857 B
Nix

{
description = "A Nix-flake-based Java development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
jdk = "jdk17";
config = {
packageOverrides = p: {
gradle = (p.gradle.override { java = p.${jdk}; });
};
};
pkgs = import nixpkgs { inherit config jdk system; };
java = pkgs.${jdk};
buildTools = with pkgs; [ ant gradle maven ];
inherit (pkgs) mkShell;
in {
devShells = {
default = mkShell {
buildInputs = [ java ] ++ buildTools;
shellHook = ''
${java}/bin/java -version
'';
};
};
});
}