#!/usr/bin/env nu let dotfiles = ($env.HOME | path join "nixos-config/dotfiles") let config = ($env.HOME | path join ".config") # iterate over all files in dotfiles/ glob $"($dotfiles)/**/*" | where ($it | path type) == "file" | each {|file| let rel = ($file | str replace $"($dotfiles)/" "") let target = ($config | path join $rel) let target_dir = ($target | path dirname) # ensure parent dir exists mkdir $target_dir # skip if already correctly symlinked if ($target | path type) == "symlink" { return } # back up existing file if ($target | path exists) { print $"backing up ($target) → ($target).bak" mv $target $"($target).bak" } print $"linking ($target) → ($file)" ln -s $file $target }