!FBuJyWXTGcGtHTPphC:nixos.org

Nix Rust

718 Members
Rust163 Servers

Load older messages


SenderMessageTime
17 Jan 2026
@mirrorwake:matrix.orgroxie changed their profile picture.03:37:35
@debtquity:matrix.orgdebtquity

are there any tricks for speeding up local build times for rust packages in nixpkgs?

...
┏━ Dependency Graph:
┃ ✔ stalwart-0.15.3 ⏱ 21m29s
┣━━━ Builds
┗━ ∑ ⏵ 0 │ ✔ 1 │ ⏸ 0 │ Finished at 22:18:53 after 21m38s

20 minutes is wild

06:04:49
@charles:computer.surgeryCharles ⚡️ try disabling runtime performance optimizations like codegen-units = 1 and lto = true https://github.com/stalwartlabs/stalwart/blob/22fc4a795d56264aefd082040c6998c9371b83aa/Cargo.toml#L46-L47 06:21:37
@charles:computer.surgeryCharles ⚡️not sure if that fits your "local" criteria though06:22:30
@debtquity:matrix.orgdebtquityoh, i was hoping to do it from the building side without modifying the project06:22:44
@charles:computer.surgeryCharles ⚡️i don't know any such tricks unfortunately (but maybe someone else might?)06:23:11
@charles:computer.surgeryCharles ⚡️ i mean, you could add patches to the derivation to make those changes via overrideAttrs, unless you really mean "without changing any nix code or upstream code" 06:25:20
@debtquity:matrix.orgdebtquityah, i'll give that a shot. what do we lose with LTO, though?06:26:09
@charles:computer.surgeryCharles ⚡️https://doc.rust-lang.org/cargo/reference/profiles.html#lto06:26:46
@charles:computer.surgeryCharles ⚡️summary to the point of being unhelpful: you lose some performance06:27:20
@marienz:matrix.orgMarien ZwartShould be about the same performance as a non-incremental release build, if it's way slower than that you may be building at cores = 1 or something along those lines06:28:07
@debtquity:matrix.orgdebtquitymakes sense, so then whatever I write in overrideAttrs shouldn't be pushed to nixpkgs :)06:28:13
@charles:computer.surgeryCharles ⚡️yeah06:28:31
@charles:computer.surgeryCharles ⚡️for in-nixpkgs stuff the runtime performance increase is possibly worth the build time increase since it can then be pulled by multiple users from the binary cache without having to build it themselves06:30:40
@debtquity:matrix.orgdebtquity another thing i notice is that everytime i run nix build ./#package, it re-compiles all of the project. I thought rust had some build cache mechanism? 06:33:36
@charles:computer.surgeryCharles ⚡️rust does, nix doesn't06:33:51
@debtquity:matrix.orgdebtquityor maybe that's just the nature of nix?06:33:57
@debtquity:matrix.orgdebtquityooh06:33:59
@charles:computer.surgeryCharles ⚡️* rust (cargo, more accurately) does, nix doesn't06:34:00
@debtquity:matrix.orgdebtquityso nixpkgs function would need to be improved then06:34:29
@charles:computer.surgeryCharles ⚡️nix can't do incremental builds, it can only build complete derivations06:34:38
@charles:computer.surgeryCharles ⚡️you can sort of get incremental builds with nix by breaking up the build into multiple derivations, but that gets complicated06:35:03
@charles:computer.surgeryCharles ⚡️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 nixpkgs06:35:50
@charles:computer.surgeryCharles ⚡️nixpkgs 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.surgeryCharles ⚡️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" 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

Show newer messages


Back to Room ListRoom Version: 6