Change:
is a fast and multi threaded modern linker. We already have it in Nixpkgs, however, unlike , it has not been wrapped in a package so that it can find the libraries to dynamically link against. Hence, dynamic linking in in NixOS fails. This issue is created so that we can wrap mold inside a shell script, like what happens to when it is installed through or even normal . I would be open to helping port such a script for .
I have tried simply replacing the executable with in the wrapper script, but it didn't seem to work. I am not very familiar with how this script works or what I am missing For more information, see
After some discussion on Matrix (thanks !), I was able to get mold working in a dev shell by using the following snippet: Is there any way we can just expose this as a wrapped mold in Nixpkgs so we don't have to add this to every shell we need mold in?
Is this relevant anymore? In addition to , we also have now. Here's a test we have for it in :
Further work is to rename to so users have to choose explicitly

Discussion:
, testers , mold , nix-update-script <ins> , runCommandCC , mold-wrapped , hello , buildPackages , useMoldLinker </ins> }: stdenv.mkDerivation rec {

passthru = { updateScript = nix-update-script { }; <del> tests.version = testers.testVersion { package = mold; }; </del> <ins> tests = let helloTest = name: helloMold: let command = "$READELF -p .comment ${lib.getExe helloMold}"; emulator = stdenv.hostPlatform.emulator buildPackages; in runCommandCC "mold-${name}-test" { passthru = { inherit helloMold; }; } '' echo "Testing running the 'hello' binary which should be linked with 'mold'" >&2 ${emulator} ${lib.getExe helloMold} echo "Checking for mold in the '.comment' section" >&2 if output=$(${command} 2>&1); then if grep -Fw -- "mold" - <<< "$output"; then touch $out else echo "No mention of 'mold' detected in the '.comment' section" >&2 echo "The command was:" >&2 echo "${command}" >&2 echo "The output was:" >&2 echo "$output" >&2 exit 1 fi else echo -n "${command}" >&2 echo " returned a non-zero exit code." >&2 echo "$output" >&2 exit 1 fi '' ; in { version = testers.testVersion { package = mold; }; wrapped = helloTest "wrapped" (hello.overrideAttrs (previousAttrs: { nativeBuildInputs = (previousAttrs.nativeBuildInputs or [ ]) ++ [ mold-wrapped ]; NIX_CFLAGS_LINK = toString (previousAttrs.NIX_CFLAGS_LINK or "") + " -fuse-ld=mold"; })); adapter = helloTest "adapter" (hello.override (old: { stdenv = useMoldLinker old.stdenv; })); }; </ins> }; meta = with lib; { <del> description = "A faster drop-in replacement for existing Unix linkers"; </del> <ins> description = "A faster drop-in replacement for existing Unix linkers (unwrapped)"; </ins> longDescription = '' mold is a faster drop-in replacement for existing Unix linkers. It is several times faster than the LLVM lld linker. mold is designed to

useMoldLinker = stdenv: let bintools = stdenv.cc.bintools.override { extraBuildCommands = '' <del> wrap ld.mold ${../build-support/bintools-wrapper/ld-wrapper.sh} ${pkgs.mold}/bin/ld.mold wrap ld ${../build-support/bintools-wrapper/ld-wrapper.sh} ${pkgs.mold}/bin/ld.mold </del> <ins> wrap ${stdenv.cc.bintools.targetPrefix}ld.mold ${../build-support/bintools-wrapper/ld-wrapper.sh} ${pkgs.mold}/bin/ld.mold wrap ${stdenv.cc.bintools.targetPrefix}ld ${../build-support/bintools-wrapper/ld-wrapper.sh} ${pkgs.mold}/bin/ld.mold </ins> ''; }; in stdenv.override (old: {

mold = callPackage ../development/tools/mold { }; <ins> mold-wrapped = wrapBintoolsWith { bintools = mold; extraBuildCommands = '' wrap ${targetPackages.stdenv.cc.bintools.targetPrefix}ld.mold ${../build-support/bintools-wrapper/ld-wrapper.sh} ${mold}/bin/ld.mold wrap ${targetPackages.stdenv.cc.bintools.targetPrefix}mold ${../build-support/bintools-wrapper/ld-wrapper.sh} ${mold}/bin/mold ''; }; </ins> mommy = callPackage ../tools/misc/mommy { }; moon = callPackage ../development/tools/build-managers/moon/default.nix { };