Speeding up nix-build

It takes nearly 30 seconds for nix-build to get prepared for a derivation that I have (ie before it displays the derivations that need to get built). Is there a way to speed this up, or things to avoid that are slow?

what is the derivation? post it?

1 Like

I actually figured this one out on my own. I had as the first thing happening a import nixpkgs and fetchFromGitHub call to retrieve a specific version of nixpkgs, which I then imported. I replaced all that with a builtins.fetchTarball call using https://github.com/NixOS/nixpkgs/archive/${commit}.tar.gz that I then imported. Runs a hell of a lot faster now!

This is some stuff for work, so I can’t post the exact code.

3 Likes

Consider using https://github.com/nmattia/niv I don’t expect it to make things faster than you have now but it should encourage good pinning practices.

Thanks. To be honest, it’s not immediately apparent to me what it does from skimming it. Looks like I’d need more time to understand. The thing that looks like adding something to a manifest with a version sounds interesting, if it can somehow pin dependencies to a particular version. That was a complaint I got.

Overall I think my two biggest pain points are things being broken, and conventions being completely inconsistent, not so much versioning. Eg what can and can’t be overridden, differences between different languages, under the hood behavior that isn’t documented and is implicit, etc.

3 Likes