#!/usr/bin/env nu 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 }