incremental builds: add derivation override functions#167670
incremental builds: add derivation override functions#167670dasJ merged 16 commits intoNixOS:masterfrom
Conversation
|
Intriguing! Some thoughts:
|
Thanks for your input. I have changed the names and added a test. Let me know If there is more to do for testing. To your second concern: |
0080780 to
bfe0a0c
Compare
|
This is pretty cool. Interface wise i think it might be nicer to use and it seems like nothing speaks against doing it like this maybe? incrementalDrv = pkgs.buildIncremental drv;this could be done by implementing { pkgs }:
let
prepareIncrementalBuild = drv: ...;
mkIncrementalBuild = drv: ...;
in
drv: previousArtifacts:
mkIncrementalBuild (prepareIncrementalBuild drv) previousArtifactsThe tests would look slightly different but would show the same thing. |
You can not handle it that way, because there is no possibility to detect an earlier build automaticly, as nix is lacking the corresponding Support. |
Ok sorry for the noise. Now i get how it works. |
|
Yes. |
bfe0a0c to
d9335dc
Compare
|
I've added the requested tests. |
|
Does this require two copies of src? this doesn't seem to create genuine incremental builds, but require one "unaltered" source, that acts as a seed for the 2nd derivation. This can be problematic when you want to work on big projects like linux source code. |
Yes.
That is correct. "True" incremental builds are a cross-cutting concern that goes all the way down to the build tool used inside the sandbox. As such, Nix can not be solely responsible for managing the state, making such a solution fragile, unless the build tool can delegate the state management to recursive nix, which is, still, rather restrictive and an invasive requirement. @messemar Could you explain this in the Nixpkgs manual?
If you buy into Nix, you have to be ok with "wasting" some space for the benefits of reproducibility, atomicity, etc. |
Yes I can, when I have some spare time again I will. As well as continuing the implementation, of course :D |
d9335dc to
98c1c46
Compare
|
Steps to un-draft: Add a section in the nixpkgs manual. |
dasJ
left a comment
There was a problem hiding this comment.
Code looks good and functionality is lovely to have (would have helped me bisecting the kernel a couple of days ago :)
Co-authored-by: Philipp Schuster <phip1611@gmail.com>
|
There isn't |
|
Ah there is: @infinisil is it okay to dismiss your review? |
| outputs = [ "out" ]; | ||
| name = drv.name + "-checkpointArtifacts"; | ||
| # To determine differences between the state of the build directory | ||
| # from an earlier build and a later one we store the state of the build |
There was a problem hiding this comment.
nit:
| # from an earlier build and a later one we store the state of the build | |
| # from an earlier build and a later one we store the state of the build |
| cp -r ./* $out/sources/ | ||
| ''; | ||
|
|
||
| # After the build the build directory is copied again |
There was a problem hiding this comment.
| # After the build the build directory is copied again | |
| # After the build, the build directory is copied again |
| # After the build the build directory is copied again | ||
| # to get the output files. | ||
| # We copy the complete build folder, to take care for | ||
| # Build tools, building in the source directory, instead of |
There was a problem hiding this comment.
| # Build tools, building in the source directory, instead of | |
| # build tools, building in the source directory, instead of |
| # to get the output files. | ||
| # We copy the complete build folder, to take care for | ||
| # Build tools, building in the source directory, instead of | ||
| # having a build root directory, e.G the Linux kernel. |
There was a problem hiding this comment.
| # having a build root directory, e.G the Linux kernel. | |
| # having a build root directory, e.g., the Linux kernel. |
or
| # having a build root directory, e.G the Linux kernel. | |
| # having a build root directory, such as the Linux kernel. |
Stale, everything appears to be fixed
Oh yeah sorry missed this. It's okay. Generally this does seem a rather hacky, but it looks like it's good enough for a lot of use cases, so it's fine. @messemar: Though it looks like #167670 (comment) wasn't fully addressed, and I can't find a comment explaining why. Not very important though. |
I'm sure you think the same about it, but to be clear, the goal itself is hacky, as something non-hacky would have to integrate with something other than phases perhaps, in order for it to be able to give guarantees that can't be messed up by the user of this feature, but it's unclear to what that would be. |
|
@infinisil and @roberth Regarding #167670 (comment) If we use |
|
@messemar You do have Which would then also work if the source has a |
|
@infinisil Ah, now I get it. Is it a nit, or should I fix it in a follow up PR ? |
|
@messemar I'd classify it as a nice-to-have for correctness. Feel free to make a follow-up PR, but not necessarily :) |
|
Would it make sense to mention this in the 2023 recap? Or is it not supposed to be seen by too many people? 🐱 |
|
@asymmetric It needs an explicit starting state, and it only works for typical |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
|
I really, really like this idea and would like to use it in practice! However, there are some minor inconsistencies across the docs; e.g. nixpkgs/doc/build-helpers/special/checkpoint-build.section.md Lines 34 to 36 in d6b045f But the actual command is In fact, all other functions in this PR are in the form of Update: I made a draft here, along with other cosmetic changes. |
@bryango From my perspective, the change is reasonable and I like it. I would love to see a PR for this. |
incremental builds: add derivation override functions (cherry picked from commit 5eed541)
Description of changes
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)nixos/doc/manual/md-to-db.shto update generated release notes