-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevShells.nix
128 lines (116 loc) · 3.19 KB
/
devShells.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
{ pkgs, ... }:
let
shellAliases = import ./utils/shellAliases.nix;
mariadb = import ./utils/mariadb.nix;
in
{
# nix develop ".#devShells.node20"
js = pkgs.mkShell {
description = "Node.js 20 & Bun";
buildInputs = with pkgs; [
nodejs_20
(nodePackages.yarn.override { nodejs = nodejs_20; })
bun
redis
postgresql
];
shellHook = ''
${shellAliases.aliases}
# init db, create logfile, and start the postgre db
initdb -D ~/.postgres
pg_ctl -D ~/.postgres -l logfile start
pg_ctl -D ~/.postgres status
# stop database when leaving nix shell
trap "pg_ctl -D ~/.postgres stop" EXIT
'';
};
# nix develop ".#devShells.php"
php = pkgs.mkShell {
description = "PHP 8.3";
buildInputs = with pkgs; [
mariadb_110
redis
php83
php83Packages.composer
(with (php83Extensions); [pdo xml redis mongodb])
];
shellHook = ''
${shellAliases.aliases}
MYSQL_BASEDIR=${pkgs.mariadb_110}
${mariadb.command}
echo "Starting Redis..."
redis-server --daemonize yes
echo "extension=/nix/store/jdj6ml38xjsayq5zmgimlxdkbwarsmng-php-mongodb-1.17.3/lib/php/extensions/mongodb.so" > /Users/nusendra/.php-extensions/mongodb.ini
# Set PHP_INI_SCAN_DIR to include the custom directory
export PHP_INI_SCAN_DIR="/nix/store/yxlsvn4biz4b2r2hajpys297r3yqsj3r-php-with-extensions-8.3.4/lib:/Users/nusendra/.php-extensions"
echo "PHP configuration:"
php --ini
php -m | grep redis
php -m | grep mongo
'';
};
# nix develop ".#devShells.php81"
php81 = pkgs.mkShell {
description = "PHP 8.1";
buildInputs = with pkgs; [
mariadb_110
php81
php81Packages.composer
(with (php83Extensions); [pdo xml])
];
shellHook = ''
${shellAliases.aliases}
MYSQL_BASEDIR=${pkgs.mariadb_110}
${mariadb.command}
'';
};
# nix develop ".#devShells.mariadb"
mariadb = pkgs.mkShell {
description = "MariaDB";
buildInputs = with pkgs; [
mariadb_110
];
shellHook = ''
${shellAliases.aliases}
MYSQL_BASEDIR=${pkgs.mariadb_110}
${mariadb.command}
'';
};
# nix develop ".#devShells.rust"
rust = pkgs.mkShell {
description = "Rust";
buildInputs = with pkgs; [
rustc
cargo
gcc
rustfmt
rustup
];
shellHook = ''
${shellAliases.aliases}
'';
};
# elasticsearch
# nix develop ".#devshells.elasticsearch"
elasticsearch = pkgs.mkShell {
description = "ElasticSearch";
buildInputs = with pkgs; [
elasticsearch
];
shellHook = ''
# Set ES_JAVA_HOME explicitly if needed
export ES_JAVA_HOME=${pkgs.jdk}
export ES_HOME=$(dirname $(dirname $(which elasticsearch)))
export ES_PATH_CONF=$HOME/.config/nix/home-manager/elasticsearch-config
# Create a log directory with appropriate permissions
ES_LOG_DIR=$HOME/.config/nix/es-logs
mkdir -p $ES_LOG_DIR
chmod 755 $ES_LOG_DIR
ES_DATA_DIR=$HOME/elasticsearch-data
mkdir -p $ES_DATA_DIR
chmod 755 $ES_DATA_DIR
# Run Elasticsearch with the log directory specified
elasticsearch -d
'';
};
}