feat: add setup script to symlink git repository to /etc/nixos
This commit is contained in:
parent
dc55dbdc56
commit
5d20da5abc
1 changed files with 24 additions and 0 deletions
24
setup
Executable file
24
setup
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
|
||||
# this file should be run after cloning this git repository
|
||||
# to set up nixos and versioning.
|
||||
|
||||
BACKUP_SUFFIX=.bak-$(date +%Y%m%d-%H%M%S)
|
||||
|
||||
# check if /etc/nixos exists or is a symlink
|
||||
if [ -L /etc/nixos ]; then
|
||||
TARGET=$(readlink /etc/nixos)
|
||||
sudo cp -r ${TARGET} /etc/nixos${BACKUP_SUFFIX}
|
||||
sudo rm -rf /etc/nixos
|
||||
echo "/etc/nixos has been backed up to /etc/nixos${BACKUP_SUFFIX}."
|
||||
elif [ -d /etc/nixos ]; then
|
||||
sudo mv -v /etc/nixos /etc/nixos${BACKUP_SUFFIX} # back up the original config
|
||||
echo "/etc/nixos has been backed up to /etc/nixos${BACKUP_SUFFIX}."
|
||||
else
|
||||
echo "/etc/nixos does not exist. Backup not performed."
|
||||
fi
|
||||
|
||||
SCRIPT_PATH=$(realpath "$0")
|
||||
DOTFILES_PATH=$(dirname ${SCRIPT_PATH})
|
||||
sudo ln -s ${DOTFILES_PATH} /etc/nixos
|
||||
echo "${DOTFILES_PATH} has been symlinked to /etc/nixos."
|
Loading…
Add table
Add a link
Reference in a new issue