From a8b96a6f95a09053c0f669b3096ae5debf7c34b9 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 24 Jun 2020 14:44:20 +0200 Subject: [PATCH] chore(nix): add minio to shell.nix --- shell.nix | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/shell.nix b/shell.nix index c2fc68b95..f5f863611 100644 --- a/shell.nix +++ b/shell.nix @@ -19,7 +19,7 @@ let ''; override = oldAttrs: { - nativeBuildInputs = oldAttrs.nativeBuildInputs ++ (with pkgs; [ nodejs-13_x postgresql openldap google-chrome exiftool memcached ]) ++ (with pkgs.haskellPackages; [ stack yesod-bin hlint cabal-install weeder profiteur ]); + nativeBuildInputs = oldAttrs.nativeBuildInputs ++ (with pkgs; [ nodejs-13_x postgresql openldap google-chrome exiftool memcached minio minio-client ]) ++ (with pkgs.haskellPackages; [ stack yesod-bin hlint cabal-install weeder profiteur ]); shellHook = '' export PROMPT_INFO="${oldAttrs.name}" @@ -31,6 +31,7 @@ let type cleanup_widget_memcached &>/dev/null && cleanup_widget_memcached type cleanup_session_memcached &>/dev/null && cleanup_session_memcached type cleanup_cache_memcached &>/dev/null && cleanup_cache_memcached + type cleanup_minio &>/dev/null && cleanup_minio set +x } @@ -95,7 +96,7 @@ let memcached_pid=$? cleanup_session_memcached() { - [[ -n "memcached_pid" ]] && kill memcached_pid + [[ -n "$memcached_pid" ]] && kill $memcached_pid } export MEMCACHED_HOST=localhost MEMCACHED_PORT=11212 @@ -103,6 +104,30 @@ let set +xe fi + if [[ -z "$UPLOAD_S3_URL" ]]; then + set -xe + + cleanup_minio() { + [[ -n "$minio_pid" ]] && kill $minio_pid + [[ -n "$minio_dir" ]] && rm -rvf ''${minio_dir} + [[ -n "MINIO_LOGFILE" ]] && rm -rvf ''${MINIO_LOGFILE} + } + + minio_dir=$(mktemp -d) + export MINIO_LOGFILE=$(mktemp --tmpdir minio.XXXXXX.log) + + minio server --address localhost:9000 ''${minio_dir} &>''${MINIO_LOGFILE} & + minio_pid=$? + + sleep 1 + + export UPLOAD_S3_URL=http://localhost:9000 + export UPLOAD_S3_KEY_ID=$(${pkgs.jq}/bin/jq -r '.credential.accessKey' ''${minio_dir}/.minio.sys/config/config.json) + export UPLOAD_S3_KEY=$(${pkgs.jq}/bin/jq -r '.credential.secretKey' ''${minio_dir}/.minio.sys/config/config.json) + + set +xe + fi + if [ -n "$ZSH_VERSION" ]; then autoload -U +X compinit && compinit autoload -U +X bashcompinit && bashcompinit