Hi, You can indeed replace gcc by a newer version of it, but the overlay system does not allow you to do so inside the early stages of the bootstrapping. If you have to replace the early stages of the bootstrapping, then I suggest you look at `pkgs/stdenv/default.nix` and `pkgs/stdenv/linux/default.nix` and give it as argument of `pkgs/top-level/default.nix` which is currently loading this file to bootstrap the standard environment.
Otherwise, an overlay should help you with what you are looking for by replacing the `stdenv` attribute as well as all the packages used for bootstrapping. You have to replace these packages as well because you would otherwise have an inifnite loop as you try to add the new compiler to the stdenv, which would be needed for compiling the compiler it-self, due to `callPackage` taking stdenv from `self.` ```nix self: super: let ... stdenv = super.stdenvAdapters.overrideCC super.stdenv ...; # see [1] in { inherit stdenv; } // stdenv.overrides self super ``` I did something similar a while ago, to use an old version of gcc, in order to reproduce a bug which was on a different CI. You can find the detail here[1]. Note that, you might have to override the stdenv argument (and maybe others) used for building the compiler: ```nix cc.override { stdenv = super.stdenv } ``` In addition to changing the source of the derivation, otherwise you might have an infinite loop, as the compiler is by default compiled with the `callPackage` function which takes its inputs from the result of the fix-point, which is not what you want here for bootstrapping this new stdenv for every packages. About making it a cross compiler, I do not know enough, but I can only give you some pointers to `makeStdenvCross` stdenv adapter function[2]. I have not tested this for replacing the stdenv globally, but I think this will bring you closer to the final solution. Good luck. [1] https://github.com/mozilla/nixpkgs-mozilla/blob/master/release.nix#L96 [2] https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/adapters.nix#L59 On Wed, May 24, 2017 at 12:15 AM, Mateusz Czaplinski <czapko...@gmail.com> wrote: > I'm writing a local (non-nixpkgs) derivation, and I'd like to replace the > default "gcc" to be a patched gcc6 - also for all implicit dependencies in > nixpkgs. Is it possible to do that (I assume via overlays and resulting > fixpoint)? If yes, how should I write this to work? > > For background: I want to cross-compile the Linux kernel (actually, a fork - > L4Linux) to a new target platform. But setting `crossSystem` seems to > trigger rebuilding of gcc, which crashes on me because of OOM killer on > genattrtab. This I believe could be mitigated by a Nov'2016 patch to gcc > (https://patchwork.ozlabs.org/patch/695293/), so I believe I need to have it > incorporated into default gcc. This I hope would let me overcome the "out of > memory" obstacle, so that I could go back to hacking on my main task... > > When fixing this, I would much prefer not to have to fork whole nixpkgs, if > feasible. I suppose maintaining a nixpkgs fork is harder, and also sharing > sounds not so simple then as in the basic case of a single .nix file? > > I'd be grateful for any help. > Thanks, > /Mateusz. > > _______________________________________________ > nix-dev mailing list > nix-dev@lists.science.uu.nl > https://mailman.science.uu.nl/mailman/listinfo/nix-dev > -- Nicolas Pierron http://www.linkedin.com/in/nicolasbpierron - http://nbp.name/ _______________________________________________ nix-dev mailing list nix-dev@lists.science.uu.nl https://mailman.science.uu.nl/mailman/listinfo/nix-dev