Inspired by Preventing flake.nix written for remote targets from being garbage collected, I found the solution is to create a GC root.
- deploy-rs provides such an option -
--keep-result
. Yeah! - enable following options in
nix.conf
:
keep-outputs = true
keep-derivations = true
Then, the essential output will be always placed in /nix/store, even after a garbage collection.