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

View File

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