I’m trying to the path to the source of the flake (e.g. /nix/store/xxxxx-source).
Currently I’m using nix flake metadata | grep "Path" | awk '{print $2}'.
Is there a canonical way to do this?
Context:
I’m writing a small deployment script, which copies the flake and point nixos-rebuild --flake [path] to it:
I use colmena for other deployments, but want to try deploying without tools, seeing how easy it is with passing --flake to nixos-rebuild
nixos-rebuild isn’t available on mac running Nix. I think I need to push the flake to the remote server, and then trigger rebuild there via SSH, unless there’s some another command which can trigger a rebuild from a non NixOS machine.
I could just use scp and upload it to some random location… but using nix copy / nix-copy-closure is neat since it’d be removed when I run nix-collect-garbage periodically.
Note that nixos-rebuild itself is also a deployment tool. It’s a bash script, so you can see what commands it runs quite easily. It’s not actually very complicated at its core.
It sure is: nix-shell -p nixos-rebuild. I used this to deploy my Linux server from macOS for a long time until I switched to colmena.
There is no need to do such a thing. Either nix-instantiate locally, copy the resulting .drv closure to the builder and then build the copied .drv on the target or use nix-build's--store/NIX_REMOTE.
Always use Nix commands to handle Nix store paths. nix-copy-closure/nix copy can copy any Nix store path to any other Nix store.