-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswitch
executable file
·55 lines (46 loc) · 1.52 KB
/
switch
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
USER=$(whoami)
USERNAME_FILE=/etc/nixos/username.json
USERNAME_FILE_ORI=./secrets/nixos/username.json
if [[ ! -f "$USERNAME_FILE" ]]; then
sudo cp -Rf $USERNAME_FILE_ORI $USERNAME_FILE
sudo sed -i 's/\"defaultUser\": \"\"/\"defaultUser\": \"'${USER}'\"/' "$USERNAME_FILE"
fi
SECRETS_FILE_DIR="/home/${USER}/.config/nixos"
SECRETS_FILE="${SECRETS_FILE_DIR}/secrets.json"
SECRETS_FILE_ORI="./secrets/nixos/secrets.json"
if [[ ! -f "$SECRETS_FILE" ]]; then
mkdir -p $SECRETS_FILE_DIR
sudo cp -Rf $SECRETS_FILE_ORI $SECRETS_FILE
sudo chmod 600 $SECRETS_FILE
fi
PROJECT_DIR="/home/${USER}/projects"
NOTES_FILE_DIR="/home/${USER}/notes"
if [[ $1 == "work" ]]; then
PROJECT_DIR="/home/${USER}/work/projects"
NOTES_FILE_DIR="/home/${USER}/work/notes"
fi
if [[ ! -f "$PROJECT_DIR" ]]; then
mkdir -p $PROJECT_DIR
fi
NOTES_FILE="${NOTES_FILE_DIR}/notes.txt"
if [[ ! -f "$NOTES_FILE" ]]; then
mkdir -p $NOTES_FILE_DIR
touch $NOTES_FILE
fi
BAT_THEME_DIR="/home/${USER}/.config/bat/themes"
BAT_THEME="${BAT_THEME_DIR}/catppuccin.tmTheme"
BAT_THEME_ORI="./modules/common/theme/bat/catppuccin.tmTheme"
if [[ ! -f "$BAT_THEME" ]]; then
mkdir -p $BAT_THEME_DIR
sudo cp -Rf $BAT_THEME_ORI $BAT_THEME
# bat cache --build
fi
yubi=`ps -e | command -v yubikey-touch-detector | wc -l`
if [ $yubi -gt 0 ]; then
systemctl --user enable --now yubikey-touch-detector.service
fi
# rm -f flake.lock
# nix-collect-garbage
# sudo nix-channel --update
sudo nixos-rebuild switch --flake ./#$1 --impure