From 7fe9b3fda1635d729ab4da641f99f777f76b0e85 Mon Sep 17 00:00:00 2001 From: despiegk Date: Sat, 13 Jan 2024 14:42:36 +0300 Subject: [PATCH] v --- .gitignore | 6 +++ README.md | 24 +++++++++++- bash_shell.sh | 10 +++++ hero_shell.sh | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++ push_code.sh | 10 +++++ shell.nix | 29 ++++++++++++++ start.sh | 9 +++++ 7 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100755 bash_shell.sh create mode 100755 hero_shell.sh create mode 100755 push_code.sh create mode 100644 shell.nix create mode 100755 start.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0b97aeb --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.mypy_cache +deluge_conf +bin/ +code/ +nuscripts +nuscripts/* \ No newline at end of file diff --git a/README.md b/README.md index fad7667..cb24e58 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,24 @@ -# crystaldev +# my crystal development environment + +- make sure nix is installed + +```bash +#go to the cloned repo + +#following will start your virtual shell +./start.sh + +#then in the shell open the hero shell (based on nushell, will set all paths to make this dir sandboxed) +./hero_shell.sh + +#if you want hero and mycelium do +herotools install_hero + +#if you want mycelium +herotools install_mycelium + +#install v & crystallib +herotools install_crystal + +``` diff --git a/bash_shell.sh b/bash_shell.sh new file mode 100755 index 0000000..fffc2d2 --- /dev/null +++ b/bash_shell.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -e + +clear + +export BASE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +export PATH=${BASE}/bin:${BASE}/v:${PATH} + +cd ${BASE} +bash \ No newline at end of file diff --git a/hero_shell.sh b/hero_shell.sh new file mode 100755 index 0000000..09c2e42 --- /dev/null +++ b/hero_shell.sh @@ -0,0 +1,105 @@ +#!/bin/bash +set -e + +clear + +export BASE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +export NU_CONFIG_DIR=${BASE}/nuscripts/config + + +#keys used to see how to checkout code, don't remove +if [[ -z "$SSH_AUTH_SOCK" ]]; then + echo " - SSH agent is not running." + export sshkeys='' +else + export sshkeys=$(ssh-add -l) +fi + + +function gitcheck { + # Check if Git email is set + if [ -z "$(git config user.email)" ]; then + echo "Git email is not set." + read -p "Enter your Git email: " git_email + git config --global user.email "$git_email" + else + echo "Git email is set to: $(git config user.email)" + fi +} + + +function github_keyscan { + mkdir -p ~/.ssh + if ! grep github.com ~/.ssh/known_hosts > /dev/null + then + ssh-keyscan github.com >> ~/.ssh/known_hosts + fi + git config --global pull.rebase false + +} + +function nuscript_get { + gitcheck + github_keyscan + export DIR_CODE=$BASE/code + mkdir -p $DIR_CODE + if [[ -d "$DIR_CODE/nuscripts" ]] + then + echo + else + pushd $DIR_CODE 2>&1 >> /dev/null + if [[ -z "$sshkeys" ]]; then + git clone --depth 1 --no-single-branch https://git.ourworld.tf/despiegk/nuscripts.git + else + git clone --depth 1 --no-single-branch git@git.ourworld.tf:despiegk/nuscripts.git + fi + popd 2>&1 >> /dev/null + fi + rm -f $BASE/nuscripts + ln -s "$DIR_CODE/nuscripts" $BASE/nuscripts +} + + + +# run_hero() { +# hero 2>&1 > /dev/null +# exit_status=$? +# if [ $exit_status -ne 0 ]; then +# echo "Failed to start Hero Cmd." +# echo "If you're on macOS and encountering security restrictions." +# echo "You can do this in System Preferences > Security & Privacy." +# echo "Under the Privacy tab, add the Terminal and other Apps from this Distro" +# echo "to the list of applications with Access." +# fi +# } + +# run_nu() { +# nu -h 2>&1 > /dev/null +# exit_status=$? +# if [ $exit_status -ne 0 ]; then +# echo "Failed to start Nushell." +# fi +# } + +# run_mycelium() { +# mycelium -h 2>&1 > /dev/null +# exit_status=$? +# if [ $exit_status -ne 0 ]; then +# echo "Failed to start Nushell." +# echo "If you're on macOS and encountering security restrictions." +# echo "You can do this in System Preferences > Security & Privacy." +# echo "Under the Privacy tab, add the Terminal and other Apps from this Distro" +# echo "to the list of applications with Access." +# fi +# } + + +# run_hero +# run_nu +# run_mycelium + +cd ${BASE} + +nuscript_get + +nu --config nuscripts/config/config.nu --env-config nuscripts/config/env.nu -e 'source nuscripts/load.nu; $env.PATH = (paths_nix)' \ No newline at end of file diff --git a/push_code.sh b/push_code.sh new file mode 100755 index 0000000..541bf4c --- /dev/null +++ b/push_code.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -e + +MYDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd "$MYDIR" + +echo "Enter the commit message:" +read commit_message + +git add . -A ; git commit -m "$commit_message"; git push \ No newline at end of file diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..929cf06 --- /dev/null +++ b/shell.nix @@ -0,0 +1,29 @@ +let + nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-23.11"; + pkgs = import nixpkgs { config = {}; overlays = []; }; +in + +pkgs.mkShell { + packages = with pkgs; [ + git + nushell + mc + jq + # vscode-with-extensions + # libtorrent-rasterbar + # python311Packages.libtorrent-rasterbar + python311Full + python311Packages.ipython + python311Packages.ipdb + python311Packages.rq + rsync + rustc + go + + ]; + # shellHook = '' + # echo "Nix shell environment is ready." + # hero_shell.sh + # ''; +} + diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..041c0c7 --- /dev/null +++ b/start.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +set -e + +MYDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd "$MYDIR" + +export NIXPKGS_ALLOW_UNFREE=1 +nix-shell +