mirror of
https://github.com/acaloiaro/neoq
synced 2026-07-21 10:12:18 +00:00
85 lines
2.2 KiB
Nix
85 lines
2.2 KiB
Nix
{
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
|
systems.url = "github:nix-systems/default";
|
|
devenv.url = "github:cachix/devenv/v0.6.3";
|
|
|
|
gomod2nix = {
|
|
url = "github:nix-community/gomod2nix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
|
|
outputs = {
|
|
self,
|
|
nixpkgs,
|
|
devenv,
|
|
systems,
|
|
gomod2nix,
|
|
...
|
|
} @ inputs: let
|
|
forEachSystem = nixpkgs.lib.genAttrs (import systems);
|
|
in {
|
|
devShells = forEachSystem (system: let
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
postgresPort = 5434;
|
|
redisPort = 6380;
|
|
in {
|
|
default = devenv.lib.mkShell {
|
|
inherit inputs pkgs;
|
|
modules = [
|
|
{
|
|
packages = with pkgs; [
|
|
automake
|
|
gcc
|
|
go_1_23
|
|
gomod2nix.legacyPackages.${system}.gomod2nix
|
|
gotools
|
|
golangci-lint
|
|
go-tools
|
|
gopls
|
|
pre-commit
|
|
];
|
|
|
|
enterShell = ''
|
|
export TEST_DATABASE_URL="postgres://postgres:postgres@localhost:${toString postgresPort}/neoq?sslmode=disable&pool_max_conns=250"
|
|
export TEST_REDIS_URL=localhost:${toString redisPort}
|
|
export REDIS_PASSWORD=
|
|
'';
|
|
|
|
pre-commit.hooks.gomod2nix = {
|
|
enable = true;
|
|
always_run = true;
|
|
name = "gomod2nix";
|
|
description = "Run gomod2nix before commit";
|
|
entry = "./bin/gomod2nix";
|
|
};
|
|
|
|
services = {
|
|
postgres = {
|
|
package = pkgs.postgresql_15;
|
|
enable = true;
|
|
listen_addresses = "127.0.0.1";
|
|
port = postgresPort;
|
|
initialScript = ''
|
|
CREATE USER postgres WITH PASSWORD 'postgres' SUPERUSER;
|
|
CREATE DATABASE neoq;
|
|
'';
|
|
settings = {
|
|
max_connections = 250;
|
|
log_statement = "all";
|
|
};
|
|
};
|
|
|
|
redis = {
|
|
package = pkgs.redis;
|
|
enable = true;
|
|
port = redisPort;
|
|
};
|
|
};
|
|
}
|
|
];
|
|
};
|
|
});
|
|
};
|
|
}
|