forked from hoppscotch/hoppscotch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevenv.nix
More file actions
189 lines (166 loc) · 5.06 KB
/
devenv.nix
File metadata and controls
189 lines (166 loc) · 5.06 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
{ pkgs, lib, config, inputs, ... }:
let
rosettaPkgs =
if pkgs.stdenv.isDarwin && pkgs.stdenv.isAarch64
then pkgs.pkgsx86_64Darwin
else pkgs;
darwinPackages = with pkgs; [
apple-sdk
];
linuxPackages = with pkgs; [
nodePackages.prisma
prisma-engines
libsoup_3
webkitgtk_4_1
librsvg
libappindicator
libayatana-appindicator
];
in {
packages = with pkgs; [
git
lima
colima
docker
jq
# NOTE: In case there's `Cannot find module: ... bcrypt ...` error, try `npm rebuild bcrypt`
# See: https://github.com/kelektiv/node.bcrypt.js/issues/800
# See: https://github.com/kelektiv/node.bcrypt.js/issues/1055
nodejs_22
nodePackages.typescript-language-server
nodePackages."@volar/vue-language-server"
cargo-edit
cargo-tauri
] ++ lib.optionals pkgs.stdenv.isDarwin darwinPackages
++ lib.optionals pkgs.stdenv.isLinux linuxPackages;
env = {
APP_GREET = "Hoppscotch";
DATABASE_URL = "postgresql://postgres:testpass@localhost:5432/hoppscotch?connect_timeout=300";
DOCKER_BUILDKIT = "1";
COMPOSE_DOCKER_CLI_BUILD = "1";
} // lib.optionalAttrs pkgs.stdenv.isLinux {
# NOTE: Setting these `PRISMA_*` environment variable fixes
# "Error: Failed to fetch sha256 checksum at https://binaries.prisma.sh/all_commits/<hash>/linux-nixos/libquery_engine.so.node.gz.sha256 - 404 Not Found"
# See: https://github.com/prisma/prisma/discussions/3120
PRISMA_QUERY_ENGINE_LIBRARY = "${pkgs.prisma-engines}/lib/libquery_engine.node";
PRISMA_QUERY_ENGINE_BINARY = "${pkgs.prisma-engines}/bin/query-engine";
PRISMA_SCHEMA_ENGINE_BINARY = "${pkgs.prisma-engines}/bin/schema-engine";
LD_LIBRARY_PATH = lib.makeLibraryPath [
pkgs.libappindicator
pkgs.libayatana-appindicator
];
} // lib.optionalAttrs pkgs.stdenv.isDarwin {
# Place to put macOS-specific environment variables
};
scripts = {
hello.exec = "echo hello from $APP_GREET";
e.exec = "emacs";
lima-setup.exec = "limactl start template://docker";
lima-clean.exec = "limactl rm -f $(limactl ls -q)";
colima-start.exec = "colima start --cpu 8 --memory 50";
docker-prune.exec = ''
echo "Cleaning up unused Docker resources..."
docker system prune -f
'';
docker-logs.exec = "docker logs -f hoppscotch-aio";
docker-status.exec = ''
echo "Container Status:"
docker ps -a --filter "name=hoppscotch-aio" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
'';
db-reset.exec = ''
echo "Resetting database..."
psql -U postgres -d hoppscotch -c 'DROP SCHEMA public CASCADE; CREATE SCHEMA public;'
echo "Database reset complete."
'';
docker-clean-all.exec = ''
echo "Starting complete Docker cleanup..."
echo "1/6: Stopping all running containers..."
CONTAINERS=$(docker ps -q)
if [ -n "$CONTAINERS" ]; then
docker stop $CONTAINERS
echo "✓ Containers stopped"
else
echo "• No running containers found"
fi
echo "2/6: Removing all containers..."
CONTAINERS=$(docker ps -aq)
if [ -n "$CONTAINERS" ]; then
docker rm $CONTAINERS
echo "✓ Containers removed"
else
echo "• No containers to remove"
fi
echo "3/6: Removing all images..."
IMAGES=$(docker images -q)
if [ -n "$IMAGES" ]; then
docker rmi --force $IMAGES
echo "✓ Images removed"
else
echo "• No images to remove"
fi
echo "4/6: Removing all volumes..."
VOLUMES=$(docker volume ls -q)
if [ -n "$VOLUMES" ]; then
docker volume rm $VOLUMES
echo "✓ Volumes removed"
else
echo "• No volumes to remove"
fi
echo "5/6: Removing custom networks..."
NETWORKS=$(docker network ls --filter type=custom -q)
if [ -n "$NETWORKS" ]; then
docker network rm $NETWORKS
echo "✓ Networks removed"
else
echo "• No custom networks to remove"
fi
echo "6/6: Running system prune..."
docker system prune --all --force --volumes
echo "✓ System pruned"
echo "Done!"
'';
};
enterShell = ''
git --version
echo "Hoppscotch development environment ready!"
${lib.optionalString pkgs.stdenv.isDarwin ''
# Place to put macOS-specific shell initialization
''}
${lib.optionalString pkgs.stdenv.isLinux ''
# Place to put Linux-specific shell initialization
''}
'';
enterTest = ''
echo "Running tests"
'';
dotenv.enable = true;
languages = {
typescript = {
enable = true;
};
javascript = {
package = pkgs.nodejs_22;
enable = true;
npm.enable = true;
pnpm.enable = true;
};
go = {
enable = true;
package = pkgs.go_1_25;
};
rust = {
enable = true;
channel = "nightly";
components = [
"rustc"
"cargo"
"clippy"
"rustfmt"
"rust-analyzer"
"llvm-tools-preview"
"rust-src"
"rustc-codegen-cranelift-preview"
];
};
};
}