added nix dev shell

This commit is contained in:
Leyla Becker 2025-08-16 13:34:44 -05:00
parent c0795e234a
commit 8b344d2c53
5 changed files with 113 additions and 3 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

7
.gitignore vendored
View file

@ -5,18 +5,19 @@ target/
*.bak
~$*
# Windows image file caches
Thumbs.db
# Windows folder config file
Desktop.ini
# Mac junk
.DS_Store
# IdeaJ
*.idea
*.iml
# enviroemnt packages
.direnv

25
flake.lock generated Normal file
View file

@ -0,0 +1,25 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1754725699,
"narHash": "sha256-iAcj9T/Y+3DBy2J0N+yF9XQQQ8IEb5swLFzs23CdP88=",
"rev": "85dbfc7aaf52ecb755f87e577ddbe6dbbdbc1054",
"revCount": 841808,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.841808%2Brev-85dbfc7aaf52ecb755f87e577ddbe6dbbdbc1054/01989280-4b63-70f9-95b3-49c511cb4d92/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/NixOS/nixpkgs/0.1"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

69
flake.nix Normal file
View file

@ -0,0 +1,69 @@
{
description = "A Nix-flake-based Java development environment";
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1";
outputs =
inputs:
let
javaVersion = 17;
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forEachSupportedSystem =
f:
inputs.nixpkgs.lib.genAttrs supportedSystems (
system:
f {
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ inputs.self.overlays.default ];
};
}
);
in
{
overlays.default =
final: prev:
let
jdk = prev."jdk${toString javaVersion}";
in
{
inherit jdk;
maven = prev.maven.override { jdk_headless = jdk; };
gradle = prev.gradle.override { java = jdk; };
lombok = prev.lombok.override { inherit jdk; };
};
devShells = forEachSupportedSystem (
{ pkgs }:
{
default = pkgs.mkShell {
packages = with pkgs; [
gcc
gradle
jdk
maven
ncurses
patchelf
zlib
];
shellHook =
let
loadLombok = "-javaagent:${pkgs.lombok}/share/java/lombok.jar";
prev = "\${JAVA_TOOL_OPTIONS:+ $JAVA_TOOL_OPTIONS}";
in
''
export JAVA_TOOL_OPTIONS="${loadLombok}${prev}"
'';
};
}
);
};
}

14
shell.nix Normal file
View file

@ -0,0 +1,14 @@
(
import
(
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{src = ./.;}
)
.shellNix