-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshell
executable file
·38 lines (35 loc) · 1.46 KB
/
shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p bash_5 -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/046f8835dcb9082beb75bb471c28c832e1b067b6.tar.gz
# if no arguments (just starting the shell) give the welcome message
export PROJECTR_ARGS="$@"
# the comments above^ are special
# they tell the system to process this using nix-shell
# specifically using the exact version of bash to use
export PROJECTR_FOLDER="$PWD"
export PROJECTR_HOME="$PROJECTR_FOLDER/settings/home/"
export PROJECTR_COMMANDS_FOLDER="$PROJECTR_FOLDER/settings/commands/"
#
# find and run all the startup scripts in alphabetical order
#
for file in "$PROJECTR_FOLDER/settings/shell_startup/#pre_changing_home/"*
do
# make sure its a file
if [[ -f "$file" ]]; then
source "$file"
fi
done
# create a dummy home folder to prevent any problems when starting up
__dummy_home="$PWD/settings/.cache/home/"
rm -rf "$__dummy_home" > /dev/null
mkdir -p "$__dummy_home/.cache/"
# connect the nix cache to prevent duplicates
ln -s "$HOME/.cache/nix" "$__dummy_home/.cache/nix"
# if there are arguments, treat it as a run command
if [[ -n "$PROJECTR_ARGS" ]]
then
# FIXME: I think the single quotes need to be escaped from the arguments
# run single command
HOME="$__dummy_home" nix-shell --pure --run "zsh -c '$PROJECTR_ARGS'" "$PROJECTR_FOLDER/settings/requirements/shell.nix"
else
HOME="$__dummy_home" nix-shell --pure --command "zsh" "$PROJECTR_FOLDER/settings/requirements/shell.nix"
fi