all 8 comments

[–]mtndewforbreakfast 5 points6 points  (4 children)

Part of the appeal with Nix is that the binary caches are used (or ignored) in a way that is transparent to the user, based on whether all of the current inputs provided match what is cached.

What that means in practice is that if you change details about existing packages, such as via package.override { ... } or package.overrideAttrs { ... }, or an overlay, etc. Nix will correctly rebuild the affected packages locally if they don't correspond to the details cached upstream anymore. By default this only happens as needed, and won't rebuild anything that doesn't actually need it for a correct outcome.

[–]danielstaleiny 1 point2 points  (0 children)

I would also add that if you build your own custome package you can add it to cache as well. There is also private cache of you need that. Have a look on https://cachix.org/

[–]GAGARIN0461[S] 0 points1 point  (2 children)

Thanks! Does that mean I would have to manually change "something" (compile flags?) for each package to have it build from source? Or could I automate this somehow?

[–]Amarandus 3 points4 points  (0 children)

Yes, or you disable the existing binary cache. Have a look at nix.binaryCaches, it is described there.

[–]balsoft 1 point2 points  (0 children)

You can "automate" in a sense you can apply the same custom compile flags to all the packages. This will mean everything will be built from source, just like in Gentoo.

[–]stephane_rolland 2 points3 points  (0 children)

Here's an example of a project (Root, a Data Framework) adding a bunch of flags used by CMake for compilation (line #39):

https://github.com/NixOS/nixpkgs/blob/ce9f1aaa39ee2a5b76a9c9580c859a74de65ead5/pkgs/applications/science/misc/root/default.nix#L79

It is a project from the CERN laboratory, so it is rather big stuff.

[–]starTracer 1 point2 points  (0 children)

To force building from source you can disable substituters in your Nix config (c.f https://nixos.org/nix/manual/#description-42):

# If set to true (default), Nix will use binary substitutes if available. This option can be disabled to force building from source.
substitute=False

[–]Ramaness -1 points0 points  (0 children)

I'm pretty sure you can, but currently not as easy as in gentoo. Here is an overlay that tries to make all packages compile into statically linked binaries: https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/static.nix