Let’s say I have a directory structure and some
flake.nix files in which
modules = [ ...] are used.
I’d like to somehow extract that one
flake.nix and things (other
.nix files) it references, and nothing else. Ideally all inlined to one file, but anything would be good enough.
I’m planning to have a multiple system configurations side by side, sharing common modules, then be able to extra one that I need and copy it to another system. To clarify - I don’t want to be sending the result of derivation. I want to be sending “the source code”, so the destination can build it.
Is anything like this possible? Thank you.
I don’t really understand what you want to “extra” (or what that means here), nor do I understand what you want to “send”.
Flakes, any nix expression actually, do not “send”. They get consumed, or read by other flakes/expressions.
Sorry, typo. I want to “extract” one flake from the larger body of code (multiple flakes, sharing imports etc). If possible. Not the result of the an expression. Just the expression itself, so I could possibly send it somewhere and evaluate there, without filtering manually only the needed files.
nix eval -vv prints all files accessed during evaluation. This would allow you to extract just the required files.
Currently, Nix copies each flake to the Nix store before evaluating, so the printed file paths have prefix
/nix/store/<hash>-src/. To get paths to your actual local src files, use this Nix PR.