feat: add flake.nix

This commit is contained in:
2025-03-25 17:30:11 +01:00
parent 938bd5c601
commit 746dbf0238
8 changed files with 2281 additions and 0 deletions

19
.direnv/bin/nix-direnv-reload Executable file
View File

@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -e
if [[ ! -d "/home/xeon0x/Projects/ClientServer" ]]; then
echo "Cannot find source directory; Did you move it?"
echo "(Looking for "/home/xeon0x/Projects/ClientServer")"
echo 'Cannot force reload with this script - use "direnv reload" manually and then try again'
exit 1
fi
# rebuild the cache forcefully
_nix_direnv_force_reload=1 direnv exec "/home/xeon0x/Projects/ClientServer" true
# Update the mtime for .envrc.
# This will cause direnv to reload again - but without re-building.
touch "/home/xeon0x/Projects/ClientServer/.envrc"
# Also update the timestamp of whatever profile_rc we have.
# This makes sure that we know we are up to date.
touch -r "/home/xeon0x/Projects/ClientServer/.envrc" "/home/xeon0x/Projects/ClientServer/.direnv"/*.rc

View File

@@ -0,0 +1 @@
/nix/store/64wh73gawgn91x4mdp92dxazdy2v0v05-source

View File

@@ -0,0 +1 @@
/nix/store/s1fbk6a410xn8vcaj54iqv22agyn0ria-source

View File

@@ -0,0 +1 @@
/nix/store/n7xw4vhgmr3is6kljqb8g8z37gg9339m-nix-shell-env

File diff suppressed because it is too large Load Diff

1
.envrc Normal file
View File

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

25
flake.lock generated Normal file
View File

@@ -0,0 +1,25 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1739736696,
"narHash": "sha256-zON2GNBkzsIyALlOCFiEBcIjI4w38GYOb+P+R4S8Jsw=",
"rev": "d74a2335ac9c133d6bbec9fc98d91a77f1604c1f",
"revCount": 754461,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.754461%2Brev-d74a2335ac9c133d6bbec9fc98d91a77f1604c1f/01951426-5a87-7b75-8413-1a0d9ec5ff04/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/NixOS/nixpkgs/0.1.%2A.tar.gz"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

51
flake.nix Normal file
View File

@@ -0,0 +1,51 @@
{
description = "A Nix-flake-based Java development environment";
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";
outputs = { self, nixpkgs }:
let
javaVersion = 21; # Change this value to update the whole stack
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import nixpkgs { inherit system; overlays = [ 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}"
'';
};
});
};
}