aboutsummaryrefslogtreecommitdiff
path: root/shell.nix
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2025-01-18 13:08:27 +0200
committerKamen Mladenov <kamen@syndamia.com>2025-01-19 07:46:17 +0200
commit367a7f80993306f42ae18d07a56b510fc1402b98 (patch)
tree276a5308b24da5ae10fe57cfa80659ccc27f24eb /shell.nix
parent154356fe38d79835cf3fb28aba213827e21de72b (diff)
downloadnowayforward_human-367a7f80993306f42ae18d07a56b510fc1402b98.tar
nowayforward_human-367a7f80993306f42ae18d07a56b510fc1402b98.tar.gz
nowayforward_human-367a7f80993306f42ae18d07a56b510fc1402b98.zip
feat: Add nix setup for apache hosting
Diffstat (limited to 'shell.nix')
-rw-r--r--shell.nix42
1 files changed, 42 insertions, 0 deletions
diff --git a/shell.nix b/shell.nix
index 0f0b24a..a2ad4ac 100644
--- a/shell.nix
+++ b/shell.nix
@@ -4,18 +4,57 @@ let
shellDrv =
{
mkShell,
+ gettext,
mariadb,
apacheHttpd,
...
}:
mkShell {
nativeBuildInputs = [
+ gettext
mariadb
apacheHttpd
];
# Thanks https://github.com/JianZcar/LAMP-nix-shell-env/blob/main/default.nix
shellHook = ''
+ #
+ # Apache2
+ #
+
+ : ''${SERVER_ROOT:=${apacheHttpd}}
+ : ''${SERVER_PORT:=8000}
+ : ''${ROOT_DIR:=$HOME/.config/apache}
+ : ''${REPOSITORY:=${builtins.getEnv "PWD"}}
+ export SERVER_ROOT SERVER_PORT ROOT_DIR REPOSITORY
+
+ if [ ! -d "$ROOT_DIR" ]
+ then
+ echo 'Installing apache config...'
+ mkdir -p "$ROOT_DIR"
+ for file in $(find ./apache -type f)
+ do
+ file="''${file#./apache/}"
+
+ dir="''${file%/*}"
+ [ "$dir" != "$file" ] && mkdir -p "$ROOT_DIR/$dir"
+
+ if [ "$file" != "''${file%.tpl}" ]
+ then
+ envsubst < "./apache/$file" > "$ROOT_DIR/''${file%.tpl}"
+ else
+ cp "./apache/$file" "$ROOT_DIR/$file"
+ fi
+ done
+ fi
+
+ echo 'Starting httpd...'
+ httpd -f $ROOT_DIR/httpd.conf
+
+ #
+ # Database
+ #
+
: ''${MYSQL_HOME:="$HOME/.config/mysql"}
: ''${MYSQL_DATADIR:="$MYSQL_HOME/data"}
: ''${MYSQL_PID_FILE:="$MYSQL_HOME/mysql.pid"}
@@ -74,6 +113,9 @@ let
# Start user's shell
"$(getent passwd $USER | cut -d : -f 7)"
+ echo 'Shutting down httpd...'
+ httpd -f $ROOT_DIR/httpd.conf -k stop
+
# Stop mysql
echo 'Shutting down mysql...'
mysqladmin \