pinpox / lollypops

Lollypop Operations - NixOS Deployment Tool
https://pinpox.github.io/lollypops/
GNU General Public License v3.0
118 stars 17 forks source link

Feature: Use `nix flake archive` to deploy #30

Closed pinpox closed 4 months ago

pinpox commented 6 months ago

Instead of copying via rsync, it would be cleaner to deploy using nix flake archive. This would place the flake and it's inputs in the remote's nix store and return the path when using --json

For example:

❯ nix flake archive --to ssh://root@kfbox.public --option builders-use-substituters true --json
warning: Git tree '/home/pinpox/code/github.com/pinpox/nixos' is dirty
{"inputs":{"snip": "..." },"path":"/nix/store/78vb5imcxk2rla6s13av8vdm5n3rp49m-source"}

To rebuild we would need to know that path. A possible solution would be to create a link to the path in the store in the location where the flake was deployed until now. e.g.:

ssh ln -s /nix/store/78vb5imcxk2rla6s13av8vdm5n3rp49m-source   /var/src/lollypops/flake

This way, we could the always rebuild like normal by running `nixos-rebuild switch --flake '/var/lib/lollypops/flake'

Idea is shamelessly stolen from here