-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
135 lines (125 loc) · 3.74 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
devshell-tools.url = "github:eikek/devshell-tools";
};
outputs = inputs @ {
self,
nixpkgs,
flake-utils,
devshell-tools,
}:
{
nixosConfigurations = let
services = {
services.dev-postgres = {
enable = true;
databases = ["renku_test"];
init-script = ./.devcontainer/generate_ulid_func.sql;
pgweb = {
enable = true;
database = "renku";
};
};
services.dev-spicedb = {
enable = true;
};
services.openapi-docs = {
enable = true;
openapi-spec = "http://localhost:8000/api/data/spec.json";
};
};
in {
rdsdev-vm = devshell-tools.lib.mkVm {
system = flake-utils.lib.system.x86_64-linux;
modules = [
{
virtualisation.memorySize = 2048;
networking.hostName = "rdsdev";
}
services
];
};
rsdevcnt = devshell-tools.lib.mkContainer {
system = flake-utils.lib.system.x86_64-linux;
modules = [
services
];
};
};
}
// flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
devshellToolsPkgs = devshell-tools.packages.${system};
devSettings = {
CORS_ALLOW_ALL_ORIGINS = "true";
DB_USER = "dev";
DB_NAME = "renku";
DB_PASSWORD = "dev";
PGPASSWORD = "dev";
AUTHZ_DB_KEY = "dev";
AUTHZ_DB_NO_TLS_CONNECTION = "true";
AUTHZ_DB_GRPC_PORT = "50051";
ALEMBIC_CONFIG = "./components/renku_data_services/migrations/alembic.ini";
NB_SERVER_OPTIONS__DEFAULTS_PATH = "server_defaults.json";
NB_SERVER_OPTIONS__UI_CHOICES_PATH = "server_options.json";
LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib";
POETRY_VIRTUALENVS_PREFER_ACTIVE_PYTHON = "true";
POETRY_VIRTUALENVS_OPTIONS_SYSTEM_SITE_PACKAGES = "true";
POETRY_INSTALLER_NO_BINARY = "ruff";
};
commonPackages = with pkgs; [
redis
postgresql
jq
devshellToolsPkgs.openapi-docs
spicedb
cargo
rustc
spicedb-zed
ruff
ruff-lsp
poetry
python312
pyright
rclone
];
in {
formatter = pkgs.alejandra;
devShells = rec {
default = vm;
vm = pkgs.mkShell (devSettings
// {
buildInputs =
commonPackages
++ (builtins.attrValues devshell-tools.legacyPackages.${system}.vm-scripts);
DEV_VM = "rdsdev-vm";
VM_SSH_PORT = "10022";
DB_HOST = "localhost";
DB_PORT = "15432";
AUTHZ_DB_HOST = "localhost";
});
cnt = let
# authzed-py doesn't allow to connect via non-localhost, so this must
# be run (in the background) to forward localhost:50051 to the container
forward-auth = pkgs.writeShellScriptBin "authzed-forward-localhost" ''
${pkgs.socat}/bin/socat TCP-LISTEN:50051,fork TCP:rsdevcnt:50051
'';
in
pkgs.mkShell (
devSettings
// {
buildInputs =
commonPackages
++ [forward-auth]
++ (builtins.attrValues devshell-tools.legacyPackages.${system}.cnt-scripts);
DEV_CONTAINER = "rsdevcnt";
DB_HOST = "rsdevcnt";
DB_PORT = "5432";
AUTHZ_DB_HOST = "localhost";
}
);
};
});
}