I’m modifying a package such that only flake.nix get changed,not the other source files,creating spurious rebuilding of b.I’ve tried to replace b.src with a filterSource that excludes flake.nix (on the reasoning that if the changes to it would need a rebuild,itwould already change the drv) but apparently filterSource is not supported in restricted mode.Why?
src = with builtins;filterSource(path: type:
null!=match "flake.*" path
)self;
But I’ve still got error
error: string '/nix/store/cw25vzzrmlhn16alzi5dgvadjkpfhb0p-source' cannot refer to other paths, at /nix/store/cw25vzzrmlhn16alzi5dgvadjkpfhb0p-source/flake.nix:65:29
Currently, the derivation b depends on the whole repository flake belongs to. To avoid that you need to filter the source. Normally you could use filterSource but not with flakes. When you use filterSource in a flake (you need to pass ./. instead of self, since the latter will coerce to a string with a context), you will realize that b will still keep rebuilding when flake.nix changed. This is because the name of the directory created by filterSource will depend on the initial directory, which will change when flake.nix does. The solution is to use builtins.path and explicitly specify the name. See How to make `src = ./.` in a flake.nix not change a lot? for more details.