-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
# Adapted from: https://github.com/the-nix-way/dev-templates/blob/main/kotlin/flake.nix | ||
description = "A Nix-flake-based Kotlin development environment"; | ||
|
||
inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; }; | ||
|
||
outputs = { self, nixpkgs }: | ||
let | ||
javaVersion = 20; | ||
# Some overlay to inject your dependencies (pkgs.jdk, pkgs.gradle, pkgs.kotlin) should be defined | ||
overlays = [ | ||
(final: prev: rec { | ||
jdk = prev."jdk${toString javaVersion}"; | ||
gradle = prev.gradle.override { java = jdk; }; | ||
kotlin = prev.kotlin.override { jre = jdk; }; | ||
}) | ||
]; | ||
supportedSystems = | ||
[ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; | ||
forEachSupportedSystem = f: | ||
nixpkgs.lib.genAttrs supportedSystems | ||
(system: f { pkgs = import nixpkgs { inherit system; }; }); | ||
in { | ||
devShells = forEachSupportedSystem ({ pkgs }: { | ||
# https://ryantm.github.io/nixpkgs/builders/special/fhs-environments/#sec-fhs-environments | ||
# WARNING! As I understand, with this configuration your shell will be running in a namespace. | ||
# It isolates the filesystem (or at least a part of the filesystem) to behave as a standard | ||
# FHS system. gradlew should work normally, thus handling all your dependencies by itself. | ||
# With this configuration, your only required dependency is the jdk17. | ||
# Thus it is not a packaging flake, but rather a flake to enable development for your tool. | ||
default = (pkgs.buildFHSUserEnv { | ||
name = "java-dev-env"; | ||
targetPkgs = pkgs: | ||
with pkgs; [ | ||
jdk17 | ||
# Gradle for building containers | ||
gradle | ||
# For the cli | ||
docker-compose | ||
]; | ||
runScript = "bash"; | ||
}).env; | ||
}); | ||
}; | ||
} |