#!/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."