Add Java environment

This commit is contained in:
Luc Perkins 2022-07-28 23:42:40 +02:00
parent 4504c0f122
commit 58ace59505
No known key found for this signature in database
GPG key ID: 4F102D0C16E232F2
8 changed files with 89 additions and 6 deletions

View file

@ -10,6 +10,9 @@ nix flake init --template github:the-nix-way/dev-templates#go_1_17
# Go 1.18
nix flake init --template github:the-nix-way/dev-templates#go_1_18
# Java
nix flake init --template github:the-nix-way/dev-templates#java
# Node.js
nix flake init --template github:the-nix-way/dev-templates#node

View file

@ -18,6 +18,11 @@
description = "Go 1.18 development environment";
};
java = {
path = ./java;
description = "Java development environment";
};
node = {
path = ./node;
description = "Node.js development environment";

1
java/.envrc Normal file
View file

@ -0,0 +1 @@
use flake .

42
java/flake.lock Normal file
View file

@ -0,0 +1,42 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1656928814,
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1659041591,
"narHash": "sha256-kKoy3tDZl3w0GuVlvJ6W/ERGRqeXy2+IGXL9g1a3F68=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ab0794b1ae2756411d176dd5b82843a4ae56fe6e",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

33
java/flake.nix Normal file
View file

@ -0,0 +1,33 @@
{
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
pkgs = import nixpkgs { inherit system; };
inherit (pkgs) mkShell;
java = pkgs.jdk17;
buildTools = with pkgs; [ ant gradle maven ];
in {
devShells = {
default = pkgs.mkShell {
nativeBuildInputs = [
java
] ++ buildTools;
shellHook = ''
${java}/bin/java -version
'';
};
};
}
);
}

View file

@ -16,7 +16,6 @@
nodejs = pkgs.nodejs;
pnpm = pkgs.nodePackages.pnpm;
yarn = pkgs.yarn;
in {
devShells = {
default = pkgs.mkShell {

View file

@ -20,6 +20,8 @@
rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
helpers = with pkgs; [ pkg-config ];
inherit (pkgs) mkShell;
inherit (pkgs.lib) optionals;
inherit (pkgs.stdenv) isDarwin;
@ -30,8 +32,7 @@
default = mkShell {
nativeBuildInputs = [
rust
pkgs.pkg-config
];
] ++ helpers;
buildInputs = with pkgs; [
openssl
@ -39,8 +40,7 @@
];
shellHook = ''
echo "Entering Rust env"
echo "Running `${rust}/bin/cargo --version`"
${rust}/bin/cargo --version
'';
};
};

View file

@ -21,7 +21,7 @@
];
shellHook = ''
echo "`${zigPkg}/bin/zig version`"
${zigPkg}/bin/zig version
'';
};
};