build(nix): fix recompilation issues and improve build overhead

This commit is contained in:
Yusuf Bera Ertan 2022-09-07 02:42:37 +03:00
parent 511922baa5
commit cdfb2ae040
No known key found for this signature in database
GPG Key ID: 1D8F8FAF2294D6EA
2 changed files with 50 additions and 56 deletions

View File

@ -69,11 +69,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1662176993, "lastModified": 1662507674,
"narHash": "sha256-Sy7DsGAveDUFBb6YDsUSYZd/AcXfP/MOMIwMt/NgY84=", "narHash": "sha256-vnXfje4pfTqDEqI837GCT+hNKqzfVwPen++gnLVO9F0=",
"owner": "nix-community", "owner": "nix-community",
"repo": "dream2nix", "repo": "dream2nix",
"rev": "809bc5940214744eb29778a9a0b03f161979c1b2", "rev": "5ba9061857e3e265538c9785bb56bda2bb8f9bca",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -90,11 +90,11 @@
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
}, },
"locked": { "locked": {
"lastModified": 1662298979, "lastModified": 1662507702,
"narHash": "sha256-jHAqNmTGZb9xzUXlAjZcsOGgtsswRXw+eUUjk/wGFho=", "narHash": "sha256-Q8zfpLNCJublP7t4oHizr5tgsCS4BHFk7Fc7wzWbrzE=",
"owner": "yusdacra", "owner": "yusdacra",
"repo": "nix-cargo-integration", "repo": "nix-cargo-integration",
"rev": "a415e5728613de0fe596a4bebc04483074b1c1e0", "rev": "97aa58c683ccf628175118052b3306f40ac21ca0",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -127,11 +127,11 @@
"rust-overlay": { "rust-overlay": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1662260299, "lastModified": 1662433378,
"narHash": "sha256-FYJk/Pn+VuSyl5Q3KXwTmOD7hprlv3CZPIRMGGT61IM=", "narHash": "sha256-DqMtTtIownl+UIPG1O917IH10UF0Hwql636p22vOJfw=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "fe73170ff8b29c4230c26b85e82c25c73c35481d", "rev": "12aa8ea4381b28b7a3118f96682dc3ffb13fb6b6",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -5,6 +5,7 @@
outputs = inputs: let outputs = inputs: let
lib = inputs.nci.inputs.nixpkgs.lib; lib = inputs.nci.inputs.nixpkgs.lib;
ncl = inputs.nci.lib.nci-lib;
git = let git = let
sourceInfo = inputs.self.sourceInfo; sourceInfo = inputs.self.sourceInfo;
@ -114,6 +115,7 @@
}; };
veloren-server-cli.wrapper = wrapWithAssets; veloren-server-cli.wrapper = wrapWithAssets;
}; };
disableVendoredCrateOverrides = true;
overrides = { overrides = {
cCompiler = common: common.pkgs.clang; cCompiler = common: common.pkgs.clang;
crates = common: prev: let crates = common: prev: let
@ -127,7 +129,7 @@
rustflags = ["-C", "link-arg=-fuse-ld=mold"] rustflags = ["-C", "link-arg=-fuse-ld=mold"]
EOF EOF
''; '';
in { in rec {
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
# We have to include the command output here, otherwise Nix won't run it # We have to include the command output here, otherwise Nix won't run it
@ -139,64 +141,47 @@
NIX_GIT_TAG = ""; NIX_GIT_TAG = "";
}; };
veloren-voxygen-deps = oldAttrs: { veloren-voxygen-deps = oldAttrs: {
doCheck = false; buildInputs = ncl.addBuildInputs prev (
with pkgs; [
alsa-lib
libxkbcommon
udev
xorg.libxcb
]
);
nativeBuildInputs = nativeBuildInputs =
(oldAttrs.nativeBuildInputs or []) ncl.addNativeBuildInputs prev (with pkgs; [python3 pkg-config mold]);
++ [pkgs.mold];
postConfigure = ''
${oldAttrs.postConfigure or ""}
${configMoldLinker}
'';
};
veloren-voxygen = oldAttrs: {
src = filteredSource;
buildInputs =
(oldAttrs.buildInputs or [])
++ (
with pkgs; [
alsa-lib
libxkbcommon
udev
xorg.libxcb
]
);
nativeBuildInputs =
(oldAttrs.nativeBuildInputs or [])
++ (with pkgs; [python3 pkg-config mold]);
VELOREN_USERDATA_STRATEGY = "system";
SHADERC_LIB_DIR = "${pkgs.shaderc.lib}/lib"; SHADERC_LIB_DIR = "${pkgs.shaderc.lib}/lib";
dontUseCmakeConfigure = true;
doCheck = false; doCheck = false;
preConfigure = ''
${oldAttrs.preConfigure or ""}
substituteInPlace voxygen/src/audio/soundcache.rs \
--replace \
"../../../assets/voxygen/audio/null.ogg" \
"${./assets/voxygen/audio/null.ogg}"
'';
postConfigure = '' postConfigure = ''
${oldAttrs.postConfigure or ""} ${oldAttrs.postConfigure or ""}
${configMoldLinker} ${configMoldLinker}
''; '';
}; };
veloren-voxygen = prev:
ncl.computeOverridesResult prev [
veloren-voxygen-deps
(oldAttrs: {
src = filteredSource;
VELOREN_USERDATA_STRATEGY = "system";
dontUseCmakeConfigure = true;
preConfigure = ''
${oldAttrs.preConfigure or ""}
substituteInPlace voxygen/src/audio/soundcache.rs \
--replace \
"../../../assets/voxygen/audio/null.ogg" \
"${./assets/voxygen/audio/null.ogg}"
'';
})
];
veloren-server-cli-deps = oldAttrs: { veloren-server-cli-deps = oldAttrs: {
doCheck = false; nativeBuildInputs = ncl.addNativeBuildInputs prev [pkgs.mold];
postConfigure = ''
${oldAttrs.postConfigure or ""}
${configMoldLinker}
'';
};
veloren-server-cli = oldAttrs: {
src = filteredSource;
VELOREN_USERDATA_STRATEGY = "system";
doCheck = false; doCheck = false;
@ -205,6 +190,15 @@
${configMoldLinker} ${configMoldLinker}
''; '';
}; };
veloren-server-cli = prev:
ncl.computeOverridesResult prev [
veloren-server-cli-deps
(oldAttrs: {
src = filteredSource;
VELOREN_USERDATA_STRATEGY = "system";
})
];
}; };
}; };
}; };