89 lines
1.7 KiB
Nix
89 lines
1.7 KiB
Nix
{
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
inputs,
|
|
...
|
|
}:
|
|
|
|
let
|
|
server = pkgs.buildGoModule {
|
|
pname = "metadata-agregator";
|
|
version = "0.1.0";
|
|
src = ./.;
|
|
vendorHash = "sha256-iRG3hW7lQW1c9vIfpDs110AHeoq7N3KjyvJN9K0Sjos=";
|
|
subPackages = [ "cmd/server" ];
|
|
};
|
|
in
|
|
{
|
|
languages.go.enable = true;
|
|
|
|
git-hooks.hooks = {
|
|
treefmt.enable = true;
|
|
};
|
|
|
|
treefmt = {
|
|
enable = true;
|
|
config.programs = {
|
|
nixfmt.enable = true;
|
|
gofmt.enable = true;
|
|
};
|
|
};
|
|
|
|
packages = with pkgs; [
|
|
pre-commit
|
|
gitleaks
|
|
plantuml
|
|
|
|
gopls
|
|
gotools
|
|
go-tools
|
|
golangci-lint
|
|
|
|
buf
|
|
protoc-gen-go
|
|
protoc-gen-go-grpc
|
|
|
|
grpcurl
|
|
|
|
opencode
|
|
];
|
|
|
|
services.postgres = {
|
|
enable = true;
|
|
listen_addresses = "localhost";
|
|
|
|
initialDatabases = [
|
|
{
|
|
name = "metadata_agregator";
|
|
schema = ./nix/schema/001_schema.sql;
|
|
}
|
|
];
|
|
|
|
initialScript = ''
|
|
CREATE USER agregator WITH PASSWORD 'agregator';
|
|
GRANT ALL PRIVILEGES ON DATABASE metadata_agregator TO agregator;
|
|
\c metadata_agregator
|
|
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO agregator;
|
|
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO agregator;
|
|
GRANT ALL ON SCHEMA public TO agregator;
|
|
'';
|
|
};
|
|
|
|
processes.metadata-agregator = {
|
|
exec = ''
|
|
export DATABASE_URL="postgresql://agregator:agregator@localhost/metadata_agregator?host=${config.env.PGHOST}"
|
|
cat > "$DEVENV_RUNTIME/metadata-config.yaml" <<'YAML'
|
|
server:
|
|
port: 50053
|
|
YAML
|
|
${config.outputs.server}/bin/server -config "$DEVENV_RUNTIME/metadata-config.yaml"
|
|
'';
|
|
after = [ "devenv:processes:postgres" ];
|
|
};
|
|
|
|
outputs = {
|
|
inherit server;
|
|
};
|
|
}
|