From 7a7d428131e790f9f8202a6d13fd4b1acda8e096 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Thu, 28 Jul 2022 23:54:27 +0200 Subject: [PATCH] Add Scala environment --- README.md | 5 ++++- flake.nix | 7 ++++++- gleam/flake.nix | 2 +- java/flake.nix | 2 +- node/flake.nix | 2 +- rust/flake.nix | 9 ++------- scala/.envrc | 1 + scala/flake.lock | 42 ++++++++++++++++++++++++++++++++++++++++++ scala/flake.nix | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ zig/flake.nix | 2 +- 10 files changed, 107 insertions(+), 13 deletions(-) create mode 100644 scala/.envrc create mode 100644 scala/flake.lock create mode 100644 scala/flake.nix diff --git a/README.md b/README.md index b401416..b9e85b0 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,9 @@ nix flake init --template github:the-nix-way/dev-templates#node # Rust nix flake init --template github:the-nix-way/dev-templates#rust +# Scala +nix flake init --template github:the-nix-way/dev-templates#scala + # Zig -nix flake init --template github:the-nix-way/dev-templates#rust +nix flake init --template github:the-nix-way/dev-templates#zig ``` diff --git a/flake.nix b/flake.nix index 182a349..b2f2720 100644 --- a/flake.nix +++ b/flake.nix @@ -33,7 +33,12 @@ description = "Rust development environment"; }; - zip = { + scala = { + path = ./scala; + description = "Scala development environment"; + }; + + zig = { path = ./zig; description = "Zig development environment"; }; diff --git a/gleam/flake.nix b/gleam/flake.nix index 3a5511c..9c60a79 100644 --- a/gleam/flake.nix +++ b/gleam/flake.nix @@ -16,7 +16,7 @@ in { devShells = { default = pkgs.mkShell { - nativeBuildInputs = [ + buildInputs = [ gleamPkg ]; diff --git a/java/flake.nix b/java/flake.nix index 3c67264..023aba9 100644 --- a/java/flake.nix +++ b/java/flake.nix @@ -19,7 +19,7 @@ in { devShells = { default = pkgs.mkShell { - nativeBuildInputs = [ + buildInputs = [ java ] ++ buildTools; diff --git a/node/flake.nix b/node/flake.nix index 3c945dd..c006b06 100644 --- a/node/flake.nix +++ b/node/flake.nix @@ -19,7 +19,7 @@ in { devShells = { default = pkgs.mkShell { - nativeBuildInputs = [ + buildInputs = [ nodejs pnpm (yarn.override { inherit nodejs; }) diff --git a/rust/flake.nix b/rust/flake.nix index 9052fb9..82c881b 100644 --- a/rust/flake.nix +++ b/rust/flake.nix @@ -20,7 +20,7 @@ rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; - helpers = with pkgs; [ pkg-config ]; + helpers = with pkgs; [ openssl pkg-config ]; inherit (pkgs) mkShell; inherit (pkgs.lib) optionals; @@ -30,15 +30,10 @@ devShells = { default = mkShell { - nativeBuildInputs = [ + buildInputs = [ rust ] ++ helpers; - buildInputs = with pkgs; [ - openssl - pkgconfig - ]; - shellHook = '' ${rust}/bin/cargo --version ''; diff --git a/scala/.envrc b/scala/.envrc new file mode 100644 index 0000000..a5dbbcb --- /dev/null +++ b/scala/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/scala/flake.lock b/scala/flake.lock new file mode 100644 index 0000000..26c4e97 --- /dev/null +++ b/scala/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/scala/flake.nix b/scala/flake.nix new file mode 100644 index 0000000..dbd42c4 --- /dev/null +++ b/scala/flake.nix @@ -0,0 +1,48 @@ +{ + 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"; + jdkPkg = pkgs.${jdk}; + + config = { + packageOverrides = p: { + sbt = p.sbt.override { + jre = p.${jdk}; + }; + scala_3 = p.scala_3.override { + jre = p.${jdk}; + }; + }; + }; + + pkgs = import nixpkgs { inherit config jdk system; }; + + inherit (pkgs) mkShell; + + scala = pkgs.scala_3; + + buildTools = with pkgs; [ sbt ]; + in { + devShells = { + default = pkgs.mkShell { + buildInputs = [ + scala + jdkPkg + ] ++ buildTools; + + shellHook = '' + ${scala}/bin/scala -version + ''; + }; + }; + } + ); +} diff --git a/zig/flake.nix b/zig/flake.nix index efc69bb..3023741 100644 --- a/zig/flake.nix +++ b/zig/flake.nix @@ -16,7 +16,7 @@ in { devShells = { default = pkgs.mkShell { - nativeBuildInputs = [ + buildInputs = [ zigPkg ];