-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdevenv.nix
More file actions
62 lines (53 loc) · 1.86 KB
/
Copy pathdevenv.nix
File metadata and controls
62 lines (53 loc) · 1.86 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
{ pkgs, lib, ... }:
{
languages.elixir = {
enable = true;
package = pkgs.beam.packages.erlang_27.elixir_1_18 or pkgs.elixir;
};
languages.erlang.enable = true;
# inotify-tools is Linux-only; macOS uses fsevents natively via file_system
packages = lib.optionals pkgs.stdenv.isLinux [
pkgs.inotify-tools
];
# Point mix's tailwind/esbuild wrappers at the nix-provided binaries,
# so versions come from nixpkgs instead of downloaded releases
env = {
MIX_TAILWIND_PATH = lib.getExe pkgs.tailwindcss_4;
MIX_TAILWIND_VERSION = pkgs.tailwindcss_4.version;
MIX_ESBUILD_PATH = lib.getExe pkgs.esbuild;
MIX_ESBUILD_VERSION = pkgs.esbuild.version;
};
services.postgres = {
enable = true;
package = pkgs.postgresql_17;
initialDatabases = [];
initialScript = "CREATE ROLE postgres WITH LOGIN PASSWORD 'postgres' CREATEDB;";
listen_addresses = "*";
};
scripts.start-postgres.exec = ''
echo "Starting PostgreSQL service..."
pg_ctl start -D $PGDATA -o "-p 5432" || echo "PostgreSQL may already be running or there was an error"
'';
git-hooks.hooks = {
mix-format = {
enable = true;
name = "mix format";
entry = "mix format --check-formatted";
files = "\\.(ex|exs|heex)$";
};
};
enterShell = ''
echo "Elixir version: $(elixir --version)"
echo "Erlang version: $(erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), "releases", erlang:system_info(otp_release), "OTP_VERSION"])), io:fwrite(Version), halt().' -noshell)"
# Install Hex and rebar if not already installed
mix local.hex --force --if-missing
mix local.rebar --force --if-missing
'';
enterTest = ''
# Ensure dependencies are fetched before running tests
if [ -f mix.exs ]; then
echo "Fetching dependencies for test environment..."
mix deps.get
fi
'';
}