-
-
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
builtins.filterSource
does not work in flakes
#3732
Comments
With this bug, everyone can just forget trying to use a cargo-workspace flake. Li is beginning to get lost in the dozens of git repos he uses to avoid rebuilds everywhere. But nobody is going to split their big git projects in 7 different repos to use nix. This bug deserves top-priority. |
Works for me. $ git st
A a
A flake.lock
A flake.nix
$ cat flake.nix
{
description = "A very basic flake";
outputs = { self, nixpkgs }: {
packages.x86_64-linux.hello =
with import nixpkgs { system = "x86_64-linux"; };
stdenv.mkDerivation {
name = "hello";
src = builtins.filterSource (p: t: builtins.match ".*/a" p != null) ./.;
installPhase = ''ls > $out'';
};
defaultPackage.x86_64-linux = self.packages.x86_64-linux.hello;
};
}
$ nix build
warning: Git tree '/tmp/foo' is dirty
$ cat result
a
$ nix --version
nix (Nix) 3.0pre20200829_f156513 |
The bug is easily reproducible. Here,
❯ nix --version
nix (Nix) 3.0 @Kha 's exemple is not using the flake in the same manner, or perhapes, from nix's point of view, not at all. Observation: Nix has strong build sandboxing, so it really should not matter if X 'refers to other paths' |
If it's "easily reproducible", could you please give a self-contained example? It's not clear to me what you're doing here - filtering the output of a flake in another flake...?
Oh, it absolutely does. Try using Note that the original issue was about |
I just wanted to leave a note that |
@zimbatm Thanks, but it resulted in the same error. So it seems the problem is that nix can only filter the flake inside See the systemd wrapper flake he made if curious: https://github.com/li-maisiliym-uniks/systemd Decomposing sources into smaller parts is very useful in a world where people routinely jam dozens of build targets in a single repo... |
I see, turning non-flake repos into flakes while allowing for But again, this issue is about using |
A very useful interface would be a |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/builtins-filtersource-causes-rebuilds/12564/3 |
Possibly? |
There might be some confusion about what this issue is about. There are two different problems regarding the usage of
While it could have been named better, I believe this issue is created for the second problem. It could be avoided by using |
@ilkecan it's for both actually, as both behaviors are surprising and undocumented. |
I didn't really dive into Nix codebase but from my extensive testing the way |
Is your feature request related to a problem? Please describe.
As discussed https://discourse.nixos.org/t/flakes-and-filtersource/7787
I have a flake with 2 outputs,a depends on b and b depends on ./.
In theory if I change the nix expression for a the b expression should not rebuild,but it still does as flake.nix is included in ./.
filterSource
could remove flake from ./. and avoid rebuilding b,but evaluatingfilterSource
in a flake keepgiving weird errors.Describe the solution you'd like
For
builtins.filterSource
to work inside flake like outside them.Describe alternatives you've considered
Just keeping the depency on ./. is not as bad as the flake still only includes the files tracked by the git repo,but still keep doing more rebuilds than I'd like when editing
flake.nix
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: