diff --git a/README.md b/README.md index 7d07121..b401416 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/flake.nix b/flake.nix index bf58963..182a349 100644 --- a/flake.nix +++ b/flake.nix @@ -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"; diff --git a/java/.envrc b/java/.envrc new file mode 100644 index 0000000..a5dbbcb --- /dev/null +++ b/java/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/java/flake.lock b/java/flake.lock new file mode 100644 index 0000000..26c4e97 --- /dev/null +++ b/java/flake.lock @@ -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 +} diff --git a/java/flake.nix b/java/flake.nix new file mode 100644 index 0000000..3c67264 --- /dev/null +++ b/java/flake.nix @@ -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 + ''; + }; + }; + } + ); +} diff --git a/node/flake.nix b/node/flake.nix index c96901f..3c945dd 100644 --- a/node/flake.nix +++ b/node/flake.nix @@ -16,7 +16,6 @@ nodejs = pkgs.nodejs; pnpm = pkgs.nodePackages.pnpm; yarn = pkgs.yarn; - in { devShells = { default = pkgs.mkShell { diff --git a/rust/flake.nix b/rust/flake.nix index 018ad81..9052fb9 100644 --- a/rust/flake.nix +++ b/rust/flake.nix @@ -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 ''; }; }; diff --git a/zig/flake.nix b/zig/flake.nix index 88c8ab3..efc69bb 100644 --- a/zig/flake.nix +++ b/zig/flake.nix @@ -21,7 +21,7 @@ ]; shellHook = '' - echo "`${zigPkg}/bin/zig version`" + ${zigPkg}/bin/zig version ''; }; };