Nix Rust | 704 Members | |
| Rust | 160 Servers |
| Sender | Message | Time |
|---|---|---|
| 17 Jan 2026 | ||
| so nixpkgs function would need to be improved then | 06:34:29 | |
| nix can't do incremental builds, it can only build complete derivations | 06:34:38 | |
| you can sort of get incremental builds with nix by breaking up the build into multiple derivations, but that gets complicated | 06:35:03 | |
| https://crane.dev kind of does this by splitting the nix builds into two derivations, one for all dependencies, and one for the final binary crate, which helps in some cases but not all, and can't be used in nixpkgs | 06:35:50 | |
| nixpkgs doesn't really care about incremental build times since it has to rebuild everything from scratch often enough anyway | 06:36:11 | |
| Depending on what you're doing, crane's separate derivation for dependencies can help a lot (but of course means using crane, not pure nixpkgs) | 06:36:31 | |
| and that's not the same level of incremental builds cargo can provide outside nix | 06:37:18 | |
| Heh, I didn't type that fast enough to be helpful :) | 06:38:03 | |
| i mean you clarified some stuff i left implied, not unhelpful at least | 06:40:17 | |
| while we're clarifying things, i believe this "can't" is not a "it just hasn't been done yet" situation but more a "it is not possible to do without losing the guarantee of repeatable builds which is kind of the point of nix" situation | 06:44:31 | |
| yea i am not well versed in either, but even if it's a marginal improvement. I think it would help resource wise. Just checking the build times on this project, it takes 37 minutes on hydra (build -> tests -> post install) https://hydra.nixos.org/build/318543980 | 06:47:46 | |
| a bit surprised my machine builds faster than hydra ha | 06:48:13 | |
| wow, it takes an hour on https://hydra.nixos.org/build/318543984 | 06:49:29 | |
| the thing is that improving incremental build times is irrelevant for nixpkgs because it already has so many things to build and when any of the dependencies of a thing change, it forces a clean build of the thing, so the only time you'd reap the benefits of fast incremental builds is when only leaf packages change, which i imagine is rare | 06:55:19 | |
| e.g. if you have packages X and Y, and X depends on Y, and both X and Y are comprised of multiple derivations to enable incremental builds, and Y changes, having incremental builds for X is irrelevant because you need to rebuild it from scratch now | 06:57:30 | |
| and breaking down packages into multiple derivations is pretty complex to implement | 06:58:24 | |
| so for nixpkgs the tradeoff is between time saved on builds versus time spent making builds faster, and since rebuilds are so common, it just isn't worth it | 06:59:01 | |
| * so for nixpkgs the tradeoff is between time saved on builds versus time spent making builds more incremental, and since rebuilds are so common, it just isn't worth it | 06:59:26 | |
| but in other cases there are out-of-nixpkgs tools like crane that do address this problem, because the use-case for those is working on a package outside of nixpkgs where the dependencies change relatively rarely so that you can have fast builds most of the time, and in that case the tradeoff becomes worth it | 07:00:53 | |
| you might argue that maybe it would be good to centralize efforts on such incremental build tools by implementing and using them in nixpkgs anyway so why not do that, and for that i have no answer lol. maybe some kind of social problem around disagreeing about how exactly to do implement such things, since they are more complicated than the existing one derivation per package (ish) status quo | 07:04:37 | |
| * you might argue that maybe it would be good to centralize efforts on such incremental build tools by implementing and using them in nixpkgs anyway so why not do that, and for that i have no answer lol. maybe some kind of social problem around disagreeing about how exactly to implement such things, since they are more complicated than the existing one derivation per package (ish) status quo | 07:04:51 | |
| There's also a build system element to it where in the autotools / meson world your dependencies are first built separately (so the natural way of building those with nix looks more like what crane does) while crane has to jump through some hoops to get cargo to approximate that approach | 07:05:42 | |
| yeah, teaching all the build systems how to build each increment as its own derivation is one of the challenges and sources of complexity here | 07:06:51 | |
| for example in the context of c/c++ you could attempt to take it even further and have one derivation for each object file plus one for the final link | 07:07:39 | |
| Which would probably mean throwing upstream's build system away entirely (a lot of work for little benefit for a reasonably-sized package). (Could do that for rust too, derivation per rustc invocation instead of having cargo run that) | 07:11:10 | |
| I don't think you can reasonably do this unless you can get the upstream build system to export its build graph, but unless that build system is something like bazel that also focuses on reproducible builds I doubt it's practical (...and the natural way of consuming that exported graph would be IFD so it still wouldn't work in nixpkgs) | 07:14:22 | |
| 29 Oct 2021 | ||
| 19:57:43 | ||
| 19:57:43 | ||
| 19:57:43 | ||
| 19:58:21 | ||