!FBuJyWXTGcGtHTPphC:nixos.org

Nix Rust

696 Members
Rust157 Servers

Load older messages


SenderMessageTime
17 Jan 2026
@charles:computer.surgeryCharlesnix can't do incremental builds, it can only build complete derivations06:34:38
@charles:computer.surgeryCharlesyou can sort of get incremental builds with nix by breaking up the build into multiple derivations, but that gets complicated06:35:03
@charles:computer.surgeryCharleshttps://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 nixpkgs06:35:50
@charles:computer.surgeryCharlesnixpkgs doesn't really care about incremental build times since it has to rebuild everything from scratch often enough anyway06:36:11
@marienz:matrix.orgMarien ZwartDepending 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
@marienz:matrix.orgMarien Zwartand that's not the same level of incremental builds cargo can provide outside nix06:37:18
@marienz:matrix.orgMarien ZwartHeh, I didn't type that fast enough to be helpful :)06:38:03
@charles:computer.surgeryCharles i mean you clarified some stuff i left implied, not unhelpful at least 06:40:17
@charles:computer.surgeryCharleswhile 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" situation06:44:31
@debtquity:matrix.orgdebtquityyea 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/31854398006:47:46
@debtquity:matrix.orgdebtquitya bit surprised my machine builds faster than hydra ha06:48:13
@debtquity:matrix.orgdebtquity

wow, it takes an hour on aarch64-linux

https://hydra.nixos.org/build/318543984

06:49:29
@charles:computer.surgeryCharlesthe 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 rare06:55:19
@charles:computer.surgeryCharlese.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 now06:57:30
@charles:computer.surgeryCharlesand breaking down packages into multiple derivations is pretty complex to implement06:58:24
@charles:computer.surgeryCharlesso 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 it06:59:01
@charles:computer.surgeryCharles* 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 it06:59:26
@charles:computer.surgeryCharlesbut 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 it07:00:53
@charles:computer.surgeryCharlesyou 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 quo07:04:37
@charles:computer.surgeryCharles* 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 quo07:04:51
@marienz:matrix.orgMarien ZwartThere'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 approach07:05:42
@charles:computer.surgeryCharlesyeah, teaching all the build systems how to build each increment as its own derivation is one of the challenges and sources of complexity here07:06:51
@charles:computer.surgeryCharlesfor 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 link07:07:39
@marienz:matrix.orgMarien ZwartWhich 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
@marienz:matrix.orgMarien ZwartI 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
@eveeifyeve:matrix.orgeveeifyeve
In reply to @charles:computer.surgery
nix can't do incremental builds, it can only build complete derivations
Wasn’t there a plan for this?
13:23:07
29 Oct 2021
@grahamc:nixos.org@grahamc:nixos.org set the history visibility to "world_readable".19:57:43
@grahamc:nixos.org@grahamc:nixos.org changed the room name to "" from "".19:57:43
@grahamc:nixos.org@grahamc:nixos.org changed the room topic to "" from "".19:57:43
@server_stats:nordgedanken.devServer Stats Discoverer (traveler bot) joined the room.19:58:21

Show newer messages


Back to Room ListRoom Version: 6