@@ -10,15 +10,21 @@ Usage: "$0" [OPTIONS]
1010Options:
1111 --help Display this help message
1212 --version Display version information
13- --restore_passwd Sync private passwords into system
14- --restore_homebrew Restore homebrew softwares into macOS system
15- --enable_tunnel Enable vscode tunnel for remote development
13+ --restore_passwd (Optional) Sync private passwords into system
14+ --restore_homebrew (Optional) Restore homebrew softwares into macOS system
15+ --enable_tunnel (Optional) Enable vscode tunnel for remote development
16+ --password_store (Optional) Your private password store git repository. Default is 'https://github.com/arctan95/password-store.git'
17+ --repository Your codespaces git repository to clone. Default is 'https://github.com/arctan95/codespaces.git'
18+ --flake_uri Use your Home Manager configuration at flake-uri. Default is 'github:arctan95/codespaces'
1619"
1720
1821version=" v0.1.0"
1922restore_homebrew=false
2023restore_passwd=false
2124enable_tunnel=false
25+ password_store=" https://github.com/arctan95/password-store.git"
26+ repository=" https://github.com/arctan95/codespaces.git"
27+ flake_uri=" github:arctan95/codespaces"
2228
2329while [[ " $# " -gt 0 ]]; do
2430 case " $1 " in
@@ -32,19 +38,33 @@ while [[ "$#" -gt 0 ]]; do
3238 ;;
3339 --restore_homebrew)
3440 restore_homebrew=true
41+ shift
3542 ;;
3643 --restore_passwd)
3744 restore_passwd=true
45+ shift
3846 ;;
3947 --enable_tunnel)
4048 enable_tunnel=true
49+ shift
50+ ;;
51+ --password_store)
52+ password_store=" $2 "
53+ shift 2
54+ ;;
55+ --repository)
56+ repository=" $2 "
57+ shift 2
58+ ;;
59+ --flake_uri)
60+ flake_uri=" $2 "
61+ shift 2
4162 ;;
4263 * )
4364 echo " Unknown option: $1 "
4465 exit 1
4566 ;;
4667 esac
47- shift
4868done
4969
5070# Get system information
@@ -66,7 +86,7 @@ clone_repo() {
6686 fi
6787}
6888
69- clone_repo " https://github.com/arctan95/codespaces.git " " $HOME /.codespaces"
89+ clone_repo " $repository " " $HOME /.codespaces"
7090
7191# Fix up github codespaces
7292if [ " ${CODESPACES} " = true ]; then
107127
108128echo " Installing home-manager and switching into a new generation..."
109129# Run Home Manager with experimental features
110- nix run nixpkgs#home-manager -- switch --impure --flake github:arctan95/codespaces
130+ nix run nixpkgs#home-manager -- switch --impure --flake $flake_uri
111131
112132# Check if it's a macOS system
113133if [ " $platform " = " Darwin" ]; then
@@ -144,7 +164,8 @@ if [ "$platform" = "Darwin" ]; then
144164 # Restore softwares from brewfile
145165 if [ " $restore_homebrew " = " true" ]; then
146166 echo " Restoring softwares from Brewfile..."
147- brew bundle install --file=" $HOME /.codespaces/.config/homebrew/Brewfile"
167+ ln -s " $HOME /.codespaces/.config/homebrew/Brewfile" " $HOME /.config/homebrew/Brewfile"
168+ brew bundle install --file=" $HOME /.config/homebrew/Brewfile"
148169 fi
149170fi
150171
157178# Restore private passwords
158179if [ " $restore_passwd " = " true" ]; then
159180 echo " Configurating passwords..."
160- clone_repo " https://github.com/arctan95/password-store.git " " $HOME /.password-store"
181+ clone_repo " $password_store " " $HOME /.password-store"
161182 /bin/bash " $HOME /.password-store/setup.sh"
162183fi
163184
168189
169190echo " Installing asdf plugins and packages..."
170191# Install asdf plugins and packages from .tool-versions file
171- mv " $HOME /.codespaces/.tool-versions" " $HOME "
172- cut -d ' ' -f1 " $HOME /.tool-versions" | xargs -I {} sh -c ' echo "Installing {}..."; asdf plugin add {} && asdf install {}'
192+ ln -s " $HOME /.codespaces/.tool-versions" " $HOME /.tool-versions "
193+ cut -d ' ' -f1 " $HOME /.tool-versions" | xargs -I {} sh -c ' echo "Installing {}..."; asdf plugin add {} && asdf install {}'
0 commit comments