build(nix): use mold linker

This commit is contained in:
Yusuf Bera Ertan 2022-09-02 15:47:52 +03:00
parent 5b901d9775
commit 8dba530131
No known key found for this signature in database
GPG Key ID: 1D8F8FAF2294D6EA

View File

@ -62,6 +62,14 @@
mkdir $out mkdir $out
ln -sf ${./assets} $out/assets ln -sf ${./assets} $out/assets
''; '';
configMoldLinker = ''
echo "
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=${lib.getExe pkgs.mold}"]
" >> $CARGO_HOME/config.toml
'';
in { in {
veloren-common = oldAttrs: { veloren-common = oldAttrs: {
# Disable `git-lfs` check here since we check it ourselves # Disable `git-lfs` check here since we check it ourselves
@ -71,6 +79,12 @@
NIX_GIT_HASH = prettyRev; NIX_GIT_HASH = prettyRev;
NIX_GIT_TAG = tag; NIX_GIT_TAG = tag;
}; };
veloren-voxygen-deps = oldAttrs: {
postConfigure = ''
${oldAttrs.postConfigure or ""}
${configMoldLinker}
'';
};
veloren-voxygen = oldAttrs: { veloren-voxygen = oldAttrs: {
inherit version; inherit version;
@ -101,6 +115,10 @@
"../../../assets/voxygen/audio/null.ogg" \ "../../../assets/voxygen/audio/null.ogg" \
"${./assets/voxygen/audio/null.ogg}" "${./assets/voxygen/audio/null.ogg}"
''; '';
postConfigure = ''
${oldAttrs.postConfigure or ""}
${configMoldLinker}
'';
postInstall = '' postInstall = ''
${oldAttrs.postInstall or ""} ${oldAttrs.postInstall or ""}
if [ -f $out/bin/veloren-voxygen ]; then if [ -f $out/bin/veloren-voxygen ]; then