140 lines
4.6 KiB
Nix
140 lines
4.6 KiB
Nix
{
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
inputs,
|
|
...
|
|
}:
|
|
|
|
{
|
|
imports = [ ./nix/kafka.nix ];
|
|
|
|
# https://devenv.sh/packages/
|
|
packages = [
|
|
pkgs.git
|
|
pkgs.jetbrains.idea-community-bin
|
|
pkgs.yaml-language-server
|
|
];
|
|
|
|
languages.java.enable = true;
|
|
languages.java.maven.enable = true;
|
|
languages.nix.enable = true;
|
|
|
|
# https://devenv.sh/processes/
|
|
# processes.cargo-watch.exec = "cargo-watch";
|
|
|
|
scripts =
|
|
let
|
|
datasource = "-Dspring.datasource.url=jdbc:postgresql://${config.services.postgres.listen_addresses}:5432";
|
|
startFlexinale = name: db: ''
|
|
java ${datasource}/${db} -jar flex-training-flexinale/flexinale-${name}/target/flexinale-${name}-2024.3.0-spring-boot-fat-jar.jar
|
|
'';
|
|
in
|
|
{
|
|
"monolith-run".exec = startFlexinale "monolith" "monolith";
|
|
"modulith-1-run".exec = startFlexinale "modulith-1-onion" "modulith-1";
|
|
"modulith-2-run".exec = startFlexinale "modulith-2-components" "modulith-2";
|
|
"monolith-init".exec = ''
|
|
cd ${config.env.DEVENV_ROOT}/flex-training-flexinale
|
|
mvn test -Dtest=testdata.TestDataLoader -pl flexinale-monolith -am
|
|
'';
|
|
"modulith-1-init".exec = ''
|
|
cd ${config.env.DEVENV_ROOT}/flex-training-flexinale
|
|
mvn test -Dtest=testdata.TestDataLoader -pl flexinale-modulith-1-onion -am
|
|
'';
|
|
"modulith-2-init".exec = ''
|
|
cd ${config.env.DEVENV_ROOT}/flex-training-flexinale
|
|
mvn test -Dtest=testdata.AllTestDataLoader -pl flexinale-modulith-2-components -am
|
|
'';
|
|
"distributed-init".exec = ''
|
|
cd ${config.env.DEVENV_ROOT}/flex-training-flexinale
|
|
mvn test -Dtest=testdata.AllTestDataLoader -pl flexinale-distributed -am
|
|
'';
|
|
"distributed-portal".exec = ''
|
|
java ${datasource}/distributed-besucherportal \
|
|
-Dbootstrap.servers=localhost:9092 \
|
|
-Dspring.kafka.consumer.bootstrap-servers=localhost:9092 \
|
|
-Dspring.kafka.producer.bootstrap-servers=localhost:9092 \
|
|
-jar flex-training-flexinale/flexinale-distributed/flexinale-distributed-besucherportal/target/flexinale-distributed-besucherportal-2024.3.0-spring-boot-fat-jar.jar
|
|
'';
|
|
"distributed-backoffice".exec = ''
|
|
java ${datasource}/distributed-backoffice \
|
|
-Dbootstrap.servers=localhost:9092 \
|
|
-Dspring.kafka.consumer.bootstrap-servers=localhost:9092 \
|
|
-Dspring.kafka.producer.bootstrap-servers=localhost:9092 \
|
|
-jar flex-training-flexinale/flexinale-distributed/flexinale-distributed-backoffice/target/flexinale-distributed-backoffice-2024.3.0-spring-boot-fat-jar.jar
|
|
'';
|
|
"distributed-ticketing".exec = ''
|
|
java ${datasource}/distributed-ticketing \
|
|
-Dbootstrap.servers=localhost:9092 \
|
|
-Dspring.kafka.consumer.bootstrap-servers=localhost:9092 \
|
|
-Dspring.kafka.producer.bootstrap-servers=localhost:9092 \
|
|
-jar flex-training-flexinale/flexinale-distributed/flexinale-distributed-ticketing/target/flexinale-distributed-ticketing-2024.3.0-spring-boot-fat-jar.jar
|
|
'';
|
|
};
|
|
|
|
services.kafka = {
|
|
enable = true;
|
|
clusterId = "foobar";
|
|
settings = {
|
|
"broker.id" = 1;
|
|
"node.id" = 1;
|
|
"offsets.topic.replication.factor" = 1;
|
|
"transaction.state.log.replication.factor" = 1;
|
|
"transaction.state.log.min.isr" = 1;
|
|
"process.roles" = [
|
|
"broker"
|
|
"controller"
|
|
];
|
|
"listeners" = [
|
|
"PLAINTEXT://:9092"
|
|
"FLEXINALE://:29092"
|
|
"CONTROLLER://:9093"
|
|
];
|
|
"listener.security.protocol.map" = [
|
|
"PLAINTEXT:PLAINTEXT"
|
|
"FLEXINALE:PLAINTEXT"
|
|
"CONTROLLER:PLAINTEXT"
|
|
];
|
|
"controller.quorum.voters" = [
|
|
"1@localhost:9093"
|
|
];
|
|
"controller.listener.names" = [ "CONTROLLER" ];
|
|
};
|
|
};
|
|
|
|
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/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/
|
|
}
|