Created
October 9, 2024 21:02
-
-
Save dabrowski-adam/0fd768897171b2eb02e2cd043d0d4b12 to your computer and use it in GitHub Desktop.
Nix flake for Scala development
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ! has nix_direnv_version || ! nix_direnv_version 3.0.6; then | |
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.6/direnvrc" "sha256-RYcUJaRMf8oF5LznDrlCXbkOQrywm0HDv1VjYGaJGdM=" | |
fi | |
use flake |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
description = "Scala development environment."; | |
inputs = { | |
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | |
# https://www.nixhub.io/packages/jdk-headless | |
nixpkgs-jdk = { | |
url = "github:NixOS/nixpkgs/5ed627539ac84809c78b2dd6d26a5cebeb5ae269"; # 21.0.2 | |
}; | |
# https://www.nixhub.io/packages/sbt | |
nixpkgs-sbt = { | |
url = "github:NixOS/nixpkgs/4e0c36e4dd53f35d5a6385bdae88895ec5832f70"; # 1.10.2 | |
}; | |
}; | |
outputs = { self, nixpkgs, nixpkgs-jdk, nixpkgs-sbt }: | |
let | |
systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]; | |
in | |
{ | |
devShells = builtins.listToAttrs (map (system: { | |
name = system; | |
value = rec { | |
default = let | |
pkgs = import nixpkgs { | |
inherit system; | |
overlays = [ | |
(final: prev: | |
let | |
jdk-pkg = (import nixpkgs-jdk { inherit system; }).jdk21_headless; | |
sbt-pkg = (import nixpkgs-sbt { inherit system; }).sbt; | |
in | |
prev // { | |
jdk = jdk-pkg; | |
sbt = sbt-pkg.override { jre = jdk-pkg; }; | |
metals = prev.metals.override { jre = jdk-pkg; }; | |
} | |
) | |
]; | |
}; | |
in | |
pkgs.mkShell { | |
buildInputs = [ | |
pkgs.jdk | |
pkgs.sbt | |
pkgs.metals | |
]; | |
shellHook = '' | |
export JAVA_HOME=${pkgs.jdk} | |
''; | |
}; | |
}; | |
}) systems); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment