dev-templates/java/flake.nix

37 lines
853 B
Nix
Raw Normal View History

2022-07-28 14:42:40 -07:00
{
description = "A Nix-flake-based Java development environment";
2022-08-20 03:06:53 -07:00
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs";
};
2022-07-28 14:42:40 -07:00
2022-08-20 03:06:53 -07:00
outputs = { self, flake-utils, nixpkgs }:
flake-utils.lib.eachDefaultSystem (system:
2022-07-28 14:42:40 -07:00
let
2022-07-31 08:59:22 -07:00
jdk = pkgs.jdk17;
2022-07-28 14:42:40 -07:00
2022-07-28 16:34:22 -07:00
config = {
packageOverrides = p: {
2022-07-31 08:59:22 -07:00
gradle = (p.gradle.override { java = jdk; });
2022-07-28 16:34:22 -07:00
};
};
2022-07-28 14:42:40 -07:00
2022-07-28 16:34:22 -07:00
pkgs = import nixpkgs { inherit config jdk system; };
2022-07-31 08:59:22 -07:00
java = jdk;
2022-07-28 14:42:40 -07:00
buildTools = with pkgs; [ ant gradle maven ];
2022-07-28 16:21:18 -07:00
inherit (pkgs) mkShell;
2022-08-20 04:47:43 -07:00
in
{
2022-07-28 14:42:40 -07:00
devShells = {
2022-07-28 16:21:18 -07:00
default = mkShell {
2022-07-28 15:11:05 -07:00
buildInputs = [ java ] ++ buildTools;
2022-07-28 14:42:40 -07:00
shellHook = ''
${java}/bin/java -version
'';
};
};
2022-07-28 15:11:05 -07:00
});
2022-07-28 14:42:40 -07:00
}