[Nix-dev] System-wide default build flags (was: Lwn artikle)
Peter Simons
simons at cryp.to
Thu Jul 2 18:44:36 CEST 2009
Hi Christoph,
> [Are customized build time optimisations] possible in NixOS, e.g. by
> modifying/overwriting the stdenv expression which most other
> expressions depend on, or not?
it is possible to customize default build flags. I don't know what the
current best practice is, but a while ago, I used nixpkgs.conf to modify
stdenv as follows:
replaceStdenv = { stdenv, overrideSetup }: stdenv //
{
mkDerivation = args: stdenv.mkDerivation (args //
{
makeFlags = (if args ? makeFlags then args.makeFlags else "") + "-j8 -l8";
});
};
However, although it is possible to customize the default build flags,
it is practically unfeasible. In Gentoo, ebuilds contain a lot of
know-how that deals with problematic settings. For instance, some
packages break if they're being compiled with -O3. If you have -O3 in
/etc/make.conf, then Gentoo will automatically downgrade that setting
to, say -O2, for building that particular package. Nix, on the other
hand, doesn't do any of that, so if you specify default flags that break
certain packages, then those packages will be broken.
Furthermore, those default settings will be incorporated into the hashes
of every package you build with them, so you'll have store paths that
differ from everyone else's (unless they happen to use the exact same
settings). This means that you'll never ever be able to use binary
packages from the build farm. Also, if you ever change those flags, then
you'll have to re-build your entire system.
Take care,
Peter
More information about the nix-dev
mailing list