Files
nixos-config/install.nu
T
2026-06-08 14:35:37 +02:00

30 lines
739 B
Nu
Executable File

#!/usr/bin/env nu
# use by
# 1. create file in ./dotfiles/...
# 2. run `./install.nu`
#
# this copies the files in ./dotfiles into their respective locations
let dotfiles = ($env.HOME | path join "nixos-config/dotfiles")
glob $"($dotfiles)/**/*" | where ($it | path type) == "file" | each {|file|
let rel = ($file | str replace $"($dotfiles)/" "")
let target = ($env.HOME | path join $rel)
let target_dir = ($target | path dirname)
mkdir $target_dir
if ($target | path type) == "symlink" {
return
}
if ($target | path exists) {
print $"backing up ($target)($target).bak"
mv $target $"($target).bak"
}
print $"linking ($target)($file)"
ln -s $file $target
}