70 lines
1.3 KiB
Nix
70 lines
1.3 KiB
Nix
{
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
inputs,
|
|
...
|
|
}:
|
|
|
|
{
|
|
languages.rust.enable = true;
|
|
git-hooks.hooks = {
|
|
clippy = {
|
|
enable = true;
|
|
settings.allFeatures = true;
|
|
};
|
|
treefmt.enable = true;
|
|
};
|
|
|
|
treefmt = {
|
|
enable = true;
|
|
config.programs = {
|
|
nixfmt.enable = true;
|
|
rustfmt.enable = true;
|
|
};
|
|
};
|
|
|
|
packages = with pkgs; [
|
|
git
|
|
just
|
|
protobuf
|
|
buf
|
|
grpcurl
|
|
|
|
# Protobuf generators
|
|
protoc-gen-prost-crate
|
|
protoc-gen-prost-serde
|
|
protoc-gen-tonic
|
|
protoc-gen-prost
|
|
|
|
opencode
|
|
];
|
|
|
|
services.postgres = {
|
|
enable = true;
|
|
initialDatabases = [
|
|
{
|
|
name = "toradb";
|
|
schema = ./db/schema.sql;
|
|
}
|
|
];
|
|
};
|
|
|
|
env.PGDATABASE = "toradb";
|
|
env.DATABASE_URL = "postgresql://${builtins.getEnv "USER"}@localhost/${config.env.PGDATABASE}?host=${config.env.PGHOST}";
|
|
env.TORAD_SOCKET = "${config.env.DEVENV_RUNTIME}/torad.sock";
|
|
env.TORAD_PID_FILE = "${config.env.DEVENV_RUNTIME}/torad.pid";
|
|
|
|
processes.torad = {
|
|
exec = ''
|
|
cargo run -p torad -- --socket "$TORAD_SOCKET" --pid-file "$TORAD_PID_FILE"
|
|
'';
|
|
# Waits for postgres's own readiness probe (pg_isready + SELECT 1), not just process start.
|
|
after = [ "devenv:processes:postgres" ];
|
|
};
|
|
|
|
outputs = {
|
|
tora = config.languages.rust.import ./. { };
|
|
};
|
|
}
|