diff --git a/build/devShellHook.sh b/build/devShellHook.sh index a926772..63161ce 100644 --- a/build/devShellHook.sh +++ b/build/devShellHook.sh @@ -1,33 +1,61 @@ set -e log() { - printf '\e[1m\e[38;5;87m==>\e[0m\e[1m %s.\e[0m\n' "$*" + printf "\e[1m\e[38;5;87m==>\e[0m\e[1m %s%s\e[0m\n" "$1" "${2:-.}" } exitHook() { - log "Stopping postgres" + log "Stoppar brevekorren" pg_ctl stop --pgdata=./matabas-db } -log "Checking for existing postgres directory" +log "Letar efter existerande brevekorresmapp" [ -d ./matabas-db ] || { - log "Non-existent, creating postgres directory (./matabas-db)" + log "Finns ej, skapar brevekorresmapp (./matabas-db)" pg_ctl initdb --pgdata=./matabas-db } [ -f matabas-db/matabas.log ] && { - log "Moving logs from last session into log archive (./matabas-db/matabas.log.old)" + log "Flyttar journalen från senaste sittningen till journalarkivet (./matabas-db/matabas.log.old)" cat matabas-db/matabas.log >> matabas-db/matabas.log.old rm -f matabas-db/matabas.log } -log "Starting postgres" +log "Startar brevekorren" pg_ctl start --pgdata=./matabas-db --log=./matabas-db/matabas.log --options="-p 2137 -k /tmp" trap exitHook EXIT -log "Creating database" +log "Skapar matabas" createdb -p 2137 matabas 2>>./matabas-db/matabas.log || log "Database already exists, not overwriting" -log "Environment ready!" +log "Försvensknar miljön" +_cargo() { + cuh="$1" + shift + case "$cuh" in + kör|spring) + cargo run "$@" + ;; + ny) + cargo new "$@" + ;; + pröva) + cargo test "$@" + ;; + bygg) + cargo build "$@" + ;; + enna) + cargo init "$@" + ;; + *) + echo "vafan gö du" + ;; + esac +} +alias 'last=_cargo' +alias cargo=exit + +log "Redo" "!" set +e diff --git a/flake.nix b/flake.nix index 718804f..a4c9aec 100644 --- a/flake.nix +++ b/flake.nix @@ -14,7 +14,7 @@ default = pkgs.hello; }; devShells.default = pkgs.mkShell { - packages = [ packages.default pkgs.postgresql_15_jit ]; + packages = [ packages.default pkgs.postgresql_15_jit pkgs.cargo ]; shellHook = builtins.readFile ./build/devShellHook.sh ; }; }