-
Notifications
You must be signed in to change notification settings - Fork 4
/
flake.nix
80 lines (74 loc) · 2.09 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{
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
go_1_21
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=100"
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;
enable = true;
listen_addresses = "127.0.0.1";
port = postgresPort;
initialScript = ''
CREATE USER postgres WITH PASSWORD 'postgres' SUPERUSER;
CREATE DATABASE neoq;
'';
};
redis = {
package = pkgs.redis;
enable = true;
port = redisPort;
};
};
}
];
};
});
};
}