-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
flakes: avoid copying local flake to the store when self
arg is omitted
#5551
Comments
My original alternative thought was actually to have |
If something like this is implemented, a helpful hint to point out that feature exists when you forget/don't know about it and try to import a file from the local directory would be very user friendly. |
Is there any more info on this copying and how to avoid it? I'm concerned that if I develop via |
@haroldcarr, fixing this is part of the nix-2.8 milestone. See #3121. |
@lilyball I'm not sure if you found a good workaround to this issue yet, but this felt pretty slick for the nix-direnv problem. direnv/direnv#1103. Interested to hear if you have a nicer workaround, I've seen your various issues and proposals on this topic and they're in general very reasonable and seemingly relatively straightforward to implement. |
@j-baker The workaround I settled on was just moving my flake into a subdirectory of the parent folder. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: |
Problem with the base usage of nix-direnv is that nix wants to copy over every subdirectory of a flake. (NixOS/nix#5551) Now this is fine on small 5mb projects, although a bit annoying, but when you're dealing with LLVM and 20Gb of build artifacts you don't want this. So after looking at nix-community/nix-direnv#347 and tweaking things a little to my own liking, this is the result
Is your feature request related to a problem? Please describe.
I wanted to put a
flake.nix
in the parent folder that contains a bunch of projects, including their build artifacts. I didn't have any need for a source tree, this was purely to powernix-direnv
(it just haddevShells
, one per project).The problem is attempting to evaluate the flake, even with
nix develop
, is it immediately tried to copy the whole source tree to the Nix store. This isn't something that was mentioned in the nix flake documentation. If this were a git repo then presumably it would only copy tracked files (though that can be bad enough), but in my case as this was just a path flake it tried to copy the hundreds of thousands of files comprising many gigabytes of data (as it included build artifacts).Describe the solution you'd like
At a minimum this behavior needs to be made clear. But I'd also like to be able to just omit the
self
arg to theoutputs
function. #3121 suggests copying to the store lazily, which would be excellent. But barring that, omitting theself
arg guarantees I'm not using the source tree and so it should avoid copying it.I'm not sure offhand how this should handle the flake wanting to import other files via local paths. Like #3121 this might require verifying the file against
git ls-files
for a git repo, though for a pathDescribe alternatives you've considered
Another alternative is to let me set
inputs.self.sourceFilter
to a(path: type: …)
lambda that will be given tobuiltins.filterSource
. This would be used to filter the source tree, with the exception thatflake.nix
will always be included (either that or an error if it's not).The way this could work is that
flake.nix
is evaluated in its current location with restrictions such that it cannot import any other files, and theinputs.self.source
attribute (if defined) would be evaluated to produce the source tree used to copy to the store. Then flake evaluation would proceed as normal from there.The text was updated successfully, but these errors were encountered: