build(nix): use correct linker in main derivation compile

This commit is contained in:
Yusuf Bera Ertan 2022-09-04 16:46:45 +03:00
parent 960aac307d
commit 511922baa5
No known key found for this signature in database
GPG Key ID: 1D8F8FAF2294D6EA
3 changed files with 15 additions and 17 deletions

View File

@ -115,10 +115,6 @@ systems = ["x86_64-linux"]
name = "veloren-nix" name = "veloren-nix"
key = "veloren-nix.cachix.org-1:zokfKJqVsNV6kI/oJdLF6TYBdNPYGSb+diMVQPn/5Rc=" key = "veloren-nix.cachix.org-1:zokfKJqVsNV6kI/oJdLF6TYBdNPYGSb+diMVQPn/5Rc="
[workspace.metadata.nix.crateOverride.veloren-network]
buildInputs = ["openssl"]
nativeBuildInputs = ["pkg-config"]
[patch.crates-io] [patch.crates-io]
vek = { git = "https://github.com/yoanlcq/vek.git", rev = "84d5cb65841d46599a986c5477341bea4456be26" } vek = { git = "https://github.com/yoanlcq/vek.git", rev = "84d5cb65841d46599a986c5477341bea4456be26" }
# patch wgpu so we can use wgpu-profiler crate # patch wgpu so we can use wgpu-profiler crate

View File

@ -90,11 +90,11 @@
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
}, },
"locked": { "locked": {
"lastModified": 1662234098, "lastModified": 1662298979,
"narHash": "sha256-zl52sS2Jr2lOguuC4DpLYLU+JYFzjV0xaFycwllKFAE=", "narHash": "sha256-jHAqNmTGZb9xzUXlAjZcsOGgtsswRXw+eUUjk/wGFho=",
"owner": "yusdacra", "owner": "yusdacra",
"repo": "nix-cargo-integration", "repo": "nix-cargo-integration",
"rev": "3066def381d38288a9ecdf9a620fbb756c588ec1", "rev": "a415e5728613de0fe596a4bebc04483074b1c1e0",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -127,11 +127,11 @@
"rust-overlay": { "rust-overlay": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1662173844, "lastModified": 1662260299,
"narHash": "sha256-+ZgW98Y8fZkgFSylE+Mzalumw+kw3SVivZznbJqQaj8=", "narHash": "sha256-FYJk/Pn+VuSyl5Q3KXwTmOD7hprlv3CZPIRMGGT61IM=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "8ac6d40380dc4ec86f1ff591d5c14c8ae1d77a18", "rev": "fe73170ff8b29c4230c26b85e82c25c73c35481d",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -27,6 +27,7 @@
"CHANGELOG.md" "CHANGELOG.md"
"CODE_OF_CONDUCT.md" "CODE_OF_CONDUCT.md"
"clippy.toml" "clippy.toml"
".cargo"
]; ];
ignorePaths = path: type: let ignorePaths = path: type: let
split = lib.splitString "/" path; split = lib.splitString "/" path;
@ -114,19 +115,16 @@
veloren-server-cli.wrapper = wrapWithAssets; veloren-server-cli.wrapper = wrapWithAssets;
}; };
overrides = { overrides = {
cCompiler = common: { cCompiler = common: common.pkgs.clang;
cCompiler = common.pkgs.clang;
useCCompilerBintools = true;
};
crates = common: prev: let crates = common: prev: let
pkgs = common.pkgs; pkgs = common.pkgs;
lib = pkgs.lib;
configMoldLinker = '' configMoldLinker = ''
touch $CARGO_HOME/config.toml
cat >>$CARGO_HOME/config.toml <<EOF cat >>$CARGO_HOME/config.toml <<EOF
[target.x86_64-unknown-linux-gnu] [target.x86_64-unknown-linux-gnu]
linker = "clang" linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=${lib.getExe pkgs.mold}"] rustflags = ["-C", "link-arg=-fuse-ld=mold"]
EOF EOF
''; '';
in { in {
@ -143,6 +141,10 @@
veloren-voxygen-deps = oldAttrs: { veloren-voxygen-deps = oldAttrs: {
doCheck = false; doCheck = false;
nativeBuildInputs =
(oldAttrs.nativeBuildInputs or [])
++ [pkgs.mold];
postConfigure = '' postConfigure = ''
${oldAttrs.postConfigure or ""} ${oldAttrs.postConfigure or ""}
${configMoldLinker} ${configMoldLinker}
@ -163,7 +165,7 @@
); );
nativeBuildInputs = nativeBuildInputs =
(oldAttrs.nativeBuildInputs or []) (oldAttrs.nativeBuildInputs or [])
++ (with pkgs; [python3]); ++ (with pkgs; [python3 pkg-config mold]);
VELOREN_USERDATA_STRATEGY = "system"; VELOREN_USERDATA_STRATEGY = "system";
SHADERC_LIB_DIR = "${pkgs.shaderc.lib}/lib"; SHADERC_LIB_DIR = "${pkgs.shaderc.lib}/lib";