Skip to content

Instantly share code, notes, and snippets.

@jcaesar
Created December 12, 2024 13:14
Show Gist options
  • Save jcaesar/4612c9a2051397aa2195c49a6d5902bb to your computer and use it in GitHub Desktop.
Save jcaesar/4612c9a2051397aa2195c49a6d5902bb to your computer and use it in GitHub Desktop.
copy flake and apply
#!/usr/bin/env nu
def main [target: string] {
cd $env.FILE_PWD
let flakemeta = nix flake metadata --json | from json
let flakepath = $"path:($flakemeta.path)?($flakemeta.locked | select -i lastModified narHash rev revCount | url build-query)"
let sshopts = [-q -oCompression=yes -oControlMaster=auto -oControlPath=/tmp/ssh-check-nix-build-%C -oControlPersist=60]
$env.NIX_SSHOPTS = $sshopts | str join " "
nix copy --to ssh://($target) $flakemeta.path
ssh -tt ...$sshopts $target nh os switch -Ra $"'($flakepath)'"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment