-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
support arbitrary files in flakes or filter them out #4097
Comments
Option 2 is generally the best way. Otherwise you'll always end up with files being copied that you didn't intend, even if they're supported. We could add a filter to the |
Flakes would gain tremendous utility if they could subdivide their content into smaller flakes. It would offer the utility of |
Filtering out paths would be very useful. I don't want my git-crypt secrets copied to the store, for example. |
Just ran into #3732 after banging my head against the wall. I would love for |
And I'm not even sure if everyone who does that is aware of it. When I look at https://github.com/search?q=flake.nix+git-crypt&type=code, there are quite a bunch of repositories that use git-crypt within a directory with a I personally think that either a |
I've just realised this after converting my configurations into a flake and noting that I guess this is one of those things that looks absolutely obvious if you're being working with flakes for years, but I only read a man page, a couple of blog posts and they don't mention of this. The manual should have a big warning that everything in the flake directory is going to be copied into the Nix store by default. |
I agree, it should be warned about that. Also, I still think that a In fact, I started hacking something together a few weeks ago, but didn't have time to finish. @edolstra WDYT? If other people agree, I'd finish the patch :) |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/is-it-possible-to-make-a-flake-that-has-no-source-tree/16037/6 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/tweag-nix-dev-update-24/17230/1 |
Big 👍 on Being able to ignore paths would be excellent. The current workaround is to write a |
I also think a |
When lazy-trees, #6530 makes its way into Nix, the whole flake directory won't be copied into the store, so the only purpose of a |
In case that would be useful to others, my workaround it to copy the wanted files using
Then you call it e.g. like:
The main drawback (on top of the unnecessary copy/delete) is that this depends on bash, git and tar. The commit is essentially content addressed so it's cached on the second run. |
Another place this causes issues is when using alternative source control systems, I just tried switching to using jujutsu for my local clone of a flake, but that results in the |
For rust projects (with jj), it also copies the whole |
👍 on |
One workaround for having a devshell in a Git project that doesn’t use flakes is doing something like mkdir flake/
echo /flake/ >> .git/info/exclude
# place flake.nix into flake/flake.nix
nix develop path:./flake |
Is your feature request related to a problem? Please describe.
A local flake which is not a git repo gets fetched as an ordinary path by nix. Therefore, in a flake repo you can only have file types which are supported in the nix store. This is a painful restriction: For example I created a fifo in the flake directory to quickly try something out, and suddenly the flake was completely broken because fifos aren't supported in the store. Another problem are are large files irrelevant to nix but present in the flake tree. They always get copied to the store.
It doesn't help if I make a subdirectory for the flake and import the main directory, because the inputs are also copied to the store.
Describe the solution you'd like
I'd like to have a means to filter which files belong to a flake, because adding arbitrary files to the store doesn't seem to be right.
I'm not sure what the best implementation would be. See alternatives.
Describe alternatives you've considered
src
orself
andfilterSource
support (I heard this was disabled in restricted eval mode). This attribute could be a function of the inputs, likeoutputs
. Problem: Nix must execute arbitrary code every time it accesses a flake..flakeignore
. Maybe: Try to make sense of any.*ignore
. Yet another special file. But not turing complete.filteredPath
fetcher.I don't see an elegant solution which is not turing complete or (4.).
The text was updated successfully, but these errors were encountered: