flex/devenv.nix
Alexander Kobjolke 5e1f01e14d feat: Setup development environment
The environment includes java, maven, IntelliJ and a postgres server.
2024-11-12 17:15:25 +01:00

70 lines
1.7 KiB
Nix

{
pkgs,
lib,
config,
inputs,
...
}:
{
imports = [ ];
# https://devenv.sh/packages/
packages = [
pkgs.git
pkgs.jetbrains.idea-community-bin
];
languages.java.enable = true;
languages.java.maven.enable = true;
languages.nix.enable = true;
# https://devenv.sh/processes/
# processes.cargo-watch.exec = "cargo-watch";
processes.flexinale-monolith.exec = ''
java -Dspring.datasource.url=jdbc:postgresql://localhost:5432/monolith -jar flex-training-flexinale/flexinale-monolith/target/flexinale-monolith-2024.3.0-spring-boot-fat-jar.jar
'';
# https://devenv.sh/services/
services.postgres = {
enable = true;
listen_addresses = "127.0.0.1";
initialScript =
let
createDB = n: ''
CREATE DATABASE "${n}";
GRANT ALL PRIVILEGES ON DATABASE "${n}" TO "flexinale";
'';
in
''
CREATE USER flexinale WITH SUPERUSER PASSWORD 'flexinale';
''
+ (lib.strings.concatMapStringsSep "\n" createDB [
"monolith"
"modulith-1"
"modulith-2"
"distributed-backoffice"
"distributed-besucherportal"
"distributed-ticketing"
"distributed-test"
]);
};
# https://devenv.sh/scripts/
scripts.monolith-load.exec = ''
cd ${config.env.DEVENV_ROOT}/flex-training-flexinale
mvn test -Dtest=testdata.TestDataLoader -pl flexinale-monolith -am
'';
# https://devenv.sh/tests/
enterTest = ''
echo "Running tests"
git --version | grep --color=auto "${pkgs.git.version}"
'';
# https://devenv.sh/pre-commit-hooks/
pre-commit.hooks.shellcheck.enable = true;
# See full reference at https://devenv.sh/reference/options/
}