Fix 'cleanSource' function, re-add nixpkgs Nix formatter.#2443
Fix 'cleanSource' function, re-add nixpkgs Nix formatter.#2443athas merged 1 commit intodiku-dk:masterfrom
Conversation
…ly, to prevent unnecessary rebuilds. Also re-add nixpkgs Nix formatter to flake outputs.
|
The Git integration is probably my least favourite part of Flakes. |
I used to feel the same but I hate to say that I have come to love it a lot... |
|
Also, another change that could be considered, that I did not include in this PR, is that there is the attribute The output of this would be the latest commit rev, with a |
|
To clarify, I don't mind this change, but |
The problem with the current
cleanSourceCurrently the
cleanSourcefunction grabs any files matching the list of regular expressions. In flakes, these files will be put in a new derivation, with a name based on the NAR info of the flake that has been evaluated.This means that any changes to anything that is tracked by git, will result in a
srcinput with a new name, triggering a full rebuild of anything that uses./.as a source, even if all of the files found through the regex are the exact same as the previous derivation with a different name.To test this, run
nix build, then change one character in any file tracked by git in the repo, and runnix buildagain.The solution
Use the
builtins.pathfunction to import the path, set a name (I've arbitrarily chodsenfuthark-${commit}-src), and use the regex from the oldcleanSourcein thefilterattribute. The result is that any changes to anything that does not relate to the actual build will have no impact on the build, and unnecessary rebuilds are avoided.The code added is lifted from the nixpkgs lib, and edited to match the existing
cleanSourcefunction. Therefore it should be super robust, and unlikely to ever break.I have built every package in the repo, and everything builds successfully, works, and it resilient to being needlessly rebuilt on arbitrary changes.
Other changes
I have re-added the nixpkgs Nix formatter as
formatterin the flake output. It only takes up one line of code, and will be immensely useful for making changes to the Nix code in the future.