diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-07-22 01:16:01 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-07-22 01:16:01 +0200 |
commit | 8eb07d94a12f0fb8d4a8f15043aedc8cadd7c676 (patch) | |
tree | 647e9737344bef2206b082222d7ff87307fd91c2 /shells | |
download | Nixies-8eb07d94a12f0fb8d4a8f15043aedc8cadd7c676.tar.gz Nixies-8eb07d94a12f0fb8d4a8f15043aedc8cadd7c676.tar.zst Nixies-8eb07d94a12f0fb8d4a8f15043aedc8cadd7c676.zip |
Initial commit
Diffstat (limited to 'shells')
-rw-r--r-- | shells/README.md | 3 | ||||
-rw-r--r-- | shells/ipython.nix | 4 | ||||
-rw-r--r-- | shells/mysql.nix | 26 | ||||
-rw-r--r-- | shells/postgresql.nix | 26 | ||||
-rw-r--r-- | shells/sub_bash.nix | 16 |
5 files changed, 75 insertions, 0 deletions
diff --git a/shells/README.md b/shells/README.md new file mode 100644 index 0000000..2eeef76 --- /dev/null +++ b/shells/README.md | |||
@@ -0,0 +1,3 @@ | |||
1 | This directory regroups regularly-accessed nix-shells that require (or | ||
2 | not) a bit of configuration to run and may not be trivial to write from | ||
3 | scratch. | ||
diff --git a/shells/ipython.nix b/shells/ipython.nix new file mode 100644 index 0000000..c04a08f --- /dev/null +++ b/shells/ipython.nix | |||
@@ -0,0 +1,4 @@ | |||
1 | with import <nixpkgs> {}; | ||
2 | mkShell { | ||
3 | buildInputs = [ (python3.withPackages (ps: [ ps.ipython ])) ]; | ||
4 | } | ||
diff --git a/shells/mysql.nix b/shells/mysql.nix new file mode 100644 index 0000000..58428ac --- /dev/null +++ b/shells/mysql.nix | |||
@@ -0,0 +1,26 @@ | |||
1 | with import <nixpkgs> {}; | ||
2 | mkShell { | ||
3 | buildInputs = [ mariadb ]; | ||
4 | shellHook = '' | ||
5 | export MARIADBHOST=$PWD/mysql | ||
6 | export LANG=en_US.UTF-8; | ||
7 | export LOCALE_ARCHIVE=${glibcLocales}/lib/locale/locale-archive; | ||
8 | export MYSQL_UNIX_PORT=$MARIADBHOST/mysql.sock | ||
9 | mkdir -p $MARIADBHOST | ||
10 | cat > $MARIADBHOST/my.cnf <<EOF | ||
11 | [mysqld] | ||
12 | skip-networking | ||
13 | datadir=$MARIADBHOST | ||
14 | socket=$MARIADBHOST/mysql.sock | ||
15 | EOF | ||
16 | echo 'Initializing mysql database...' | ||
17 | mysql_install_db --defaults-file=$MARIADBHOST/my.cnf --datadir=$MARIADBHOST --basedir=${mariadb} > $MARIADBHOST/LOG 2>&1 | ||
18 | mysqld --defaults-file=$MARIADBHOST/my.cnf --datadir=$MARIADBHOST --basedir=${mariadb} --pid-file=$MARIADBHOST/mariadb.pid >> $MARIADBHOST/LOG 2>&1 & | ||
19 | finish() { | ||
20 | mysqladmin shutdown | ||
21 | rm -rf "$MARIADBHOST"; | ||
22 | } | ||
23 | trap finish EXIT | ||
24 | ''; | ||
25 | } | ||
26 | |||
diff --git a/shells/postgresql.nix b/shells/postgresql.nix new file mode 100644 index 0000000..4f7bdc4 --- /dev/null +++ b/shells/postgresql.nix | |||
@@ -0,0 +1,26 @@ | |||
1 | with import <nixpkgs> {}; | ||
2 | mkShell { | ||
3 | buildInputs = [ postgresql_11 glibcLocales ]; | ||
4 | shellHook = '' | ||
5 | export PGDB="dummy"; | ||
6 | export PGDATA=$PWD/postgres | ||
7 | export PGHOST=$PWD/postgres | ||
8 | export PGPORT=5432 | ||
9 | export LOG_PATH=$PWD/postgres/LOG | ||
10 | export PGDATABASE=postgres | ||
11 | export DATABASE_URL="postgresql:///postgres?host=$PGDATA" | ||
12 | export LANG=en_US.UTF-8; | ||
13 | export LOCALE_ARCHIVE=${glibcLocales}/lib/locale/locale-archive; | ||
14 | mkdir -p $PGDATA | ||
15 | echo 'Initializing postgresql database...' | ||
16 | initdb $PGDATA --auth=trust >/dev/null | ||
17 | pg_ctl start -w -l $LOG_PATH -o "-c synchronous_commit=off -c listen_addresses= -c unix_socket_directories=$PGDATA" | ||
18 | createdb "$PGDB"; | ||
19 | finish() { | ||
20 | pg_ctl stop -m fast; | ||
21 | rm -rf "$PGDATA"; | ||
22 | } | ||
23 | trap finish EXIT | ||
24 | ''; | ||
25 | } | ||
26 | |||
diff --git a/shells/sub_bash.nix b/shells/sub_bash.nix new file mode 100644 index 0000000..656b385 --- /dev/null +++ b/shells/sub_bash.nix | |||
@@ -0,0 +1,16 @@ | |||
1 | # run with | ||
2 | # nix-shell shell.nix --run 'touch in ; tail -f in | bash & echo $! > pid' | ||
3 | # and then send commands with | ||
4 | # echo 'compute_me "1 + 3"' >> in | ||
5 | { pkgs ? import <nixpkgs> {} }: | ||
6 | pkgs.mkShell { | ||
7 | buildInputs = [ pkgs.bc ]; | ||
8 | shellHook = '' | ||
9 | compute_me() { | ||
10 | echo "$1" | bc; | ||
11 | } | ||
12 | export -f compute_me | ||
13 | |||
14 | echo "I’m ready" | ||
15 | ''; | ||
16 | } | ||