Skip to content

Instantly share code, notes, and snippets.

@jbedo
Created April 10, 2020 00:18
Show Gist options
  • Save jbedo/013d92edaef515eca3cbf4648c30c304 to your computer and use it in GitHub Desktop.
Save jbedo/013d92edaef515eca3cbf4648c30c304 to your computer and use it in GitHub Desktop.
{ nixpkgs ? import (import /home/doc/git/allvm-tools/nix/fetch-nixpkgs.nix) { }
}:
let
overlay = self: super: {
stdenv = super.overrideCC (nixpkgs.stdenv) (with nixpkgs;
wrapCCWith {
cc = wllvm;
extraBuildCommands = ''
echo CC=wllvm >> $out/nix-support/setup-hook
echo CXX=wllvm++ >> $out/nix-support/setup-hook
echo export LLVM_COMPILER=clang >> $out/nix-support/setup-hook
echo export PATH=${
lib.makeBinPath (with llvmPackages_4; [ clang llvm file ])
}:$PATH >> $out/nix-support/setup-hook
'';
});
};
nixpkgs' = import <nixpkgs> { overlays = [ overlay ]; };
libc = nixpkgs'.stdenv.mkDerivation {
name = "musl";
preConfigure = ''
export WLLVM_CONFIGURE_ONLY=1
'';
postConfigure = ''
unset WLLVM_CONFIGURE_ONLY
'';
configureFlags = [ "--target=LLVM" "--build=LLVM" ];
src = builtins.fetchurl
"https://github.com/SRI-CSL/musllvm/archive/master.tar.gz";
};
overlay' = self: super: {
stdenv = nixpkgs'.stdenv.override {
cc = nixpkgs'.stdenv.cc.override {
inherit libc;
bintools = nixpkgs'.stdenv.cc.bintools.override { inherit libc; };
};
};
};
in import <nixpkgs> { overlays = [ overlay' ]; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment