|
| 1 | +let |
| 2 | + # Pin some fairly new nixpkgs |
| 3 | + sources = builtins.fetchTarball { |
| 4 | + name = "nixpkgs-unstable-2021-07-06"; |
| 5 | + url = "https://github.com/nixos/nixpkgs/archive/291b3ff5af268eb7a656bb11c73f2fe535ea2170.tar.gz"; |
| 6 | + sha256 = "1z2l7q4cmiaqb99cd8yfisdr1n6xbwcczr9020ss47y2z1cn1x7x"; |
| 7 | + }; |
| 8 | + |
| 9 | + # For bootstrapping |
| 10 | + pkgs = import sources { |
| 11 | + overlays = [ |
| 12 | + (pkgs: super: { |
| 13 | + # TODO replace with proper packaging once https://github.com/NixOS/nixpkgs/pull/128889 is merged |
| 14 | + mold = pkgs.stdenv.mkDerivation { |
| 15 | + pname = "mold"; |
| 16 | + version = "0.9.1"; |
| 17 | + src = ./.; |
| 18 | + nativeBuildInputs = with pkgs; [ clang_12 cmake lld_12 tbb xxHash zlib openssl git ]; |
| 19 | + dontUseCmakeConfigure = "true"; |
| 20 | + buildPhase = "make -j $NIX_BUILD_CORES"; |
| 21 | + installPhase = "mkdir -p $out $out/bin $out/share/man/man1 && PREFIX=$out make install"; |
| 22 | + }; |
| 23 | + |
| 24 | + binutils_mold = pkgs.wrapBintoolsWith { |
| 25 | + bintools = pkgs.binutils-unwrapped.overrideAttrs (old: { |
| 26 | + postInstall = '' |
| 27 | + rm $out/bin/ld.gold |
| 28 | + rm $out/bin/ld.bfd |
| 29 | + ln -sf ${pkgs.mold}/bin/mold $out/bin/ld.bfd |
| 30 | + ''; |
| 31 | + }); |
| 32 | + }; |
| 33 | + |
| 34 | + stdenv_mold = super.overrideCC super.stdenv (super.wrapCCWith rec { |
| 35 | + cc = super.gcc-unwrapped; |
| 36 | + bintools = pkgs.binutils_mold; |
| 37 | + }); |
| 38 | + }) |
| 39 | + ]; |
| 40 | + }; |
| 41 | + |
| 42 | + # Actual nixpkgs with patched linker in all packages |
| 43 | + pkgsMold = import sources { |
| 44 | + overlays = [ |
| 45 | + (self: super: { |
| 46 | + stdenv = pkgs.stdenv_mold; |
| 47 | + mold = pkgs.mold; |
| 48 | + }) |
| 49 | + ]; |
| 50 | + }; |
| 51 | + |
| 52 | + # Like pkgsMold, but we disable mold individually for known failing packages until their issues are resolved |
| 53 | + pkgsMoldCI = pkgsMold.appendOverlays [ |
| 54 | + (self: super: { |
| 55 | + inherit (pkgs) |
| 56 | + valgrind # https://github.com/rui314/mold/issues/81#issuecomment-876425070 |
| 57 | + ; |
| 58 | + }) |
| 59 | + ]; |
| 60 | +in { |
| 61 | + inherit pkgs pkgsMold pkgsMoldCI; |
| 62 | + |
| 63 | + # Packages we already know that work in order to catch regressions |
| 64 | + ciPackages = with pkgsMoldCI; linkFarmFromDrvs "packages-with-mold" [ |
| 65 | + binutils |
| 66 | + stdenv |
| 67 | + # TODO |
| 68 | + ]; |
| 69 | +} |
0 commit comments