Derivation gets always rebuilt

@waffle8946 The tip in that link is not relevant, since it’s the same source directory in use.

That said, @brodriguesco pointing src at ./. is often a cause of issues. In this case, I wager it’s because of the result symlink. When you first build, ./. contains no result symlink. Then when you build again, it’s a difference source directory, because this one has a result symlink pointing at the last result. And this results in a new build with a new result symlink. Since the result symlink is different now, the next build with have a different source again. Ad infinitum.

The fix is to filter the source. nixpkgs has a lib function called cleanSource that will filter out stuff like this and your .git directory, so you can do src = pkgs.lib.cleanSource ./.;. Or, you can use src = builtins.fetchGit ./.; to only get those files tracked by git (meaning you’ll have to git add any new files before building); providing no rev argument means it’ll get the dirty worktree. This is actually what flakes do, so using flakes is another option.

5 Likes