forked from AdamCiuris/nixos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apply-standalone
28 lines (27 loc) · 1.04 KB
/
apply-standalone
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
#!/usr/bin/bash
BASEDIR=$(readlink -f $(dirname $0))/home-manager # pwd of home-manager
hmsConfigPath=$HOME/.config/home-manager
hard-link-recursive() {
local srcDir=$1
local destDir=$2
local nixFiles=$(find $srcDir -maxdepth 1 -type f -name "*.nix")
if [ ! -d ${destDir} ]; then
echo "creating directory $destDir"
mkdir ${destDir}
fi
echo "copying [ $nixFiles ] to $destDir"
ln -fn $nixFiles ${destDir}
local dirs=$(find $srcDir -maxdepth 1 -type d -not -path '*.*' -not -path $srcDir) # all directories except the current one and hidden ones
for dir in $dirs; do
hard-link-recursive $dir $destDir/$(basename $dir)
done
}
# Clear everything in your nix home-manger config and remake.
echo "Clearing old config..."
rm -rf "${hmsConfigPath}/*"
echo "Script parent dir: $BASEDIR"
echo "Updating nix-channel..."
nix-channel --update
hard-link-recursive $BASEDIR "${hmsConfigPath}/" && \
echo "Linking done. Switching to new config."
home-manager switch -f "${hmsConfigPath}/users/$(whoami).nix"