build(nix): add source filtering for server-cli, use mold for server-cli too

This commit is contained in:
Yusuf Bera Ertan 2022-09-02 23:15:48 +03:00
parent 5bf1a0267f
commit b442b016a6
No known key found for this signature in database
GPG Key ID: 1D8F8FAF2294D6EA
2 changed files with 45 additions and 24 deletions

View File

@ -90,11 +90,11 @@
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1662143940,
"narHash": "sha256-3eJfehnZLWJGXylfpAMeLR0Q3sx8pAjGiHBQPqOH9+U=",
"lastModified": 1662158571,
"narHash": "sha256-w+iLHikl1gdbzT9bM5Iu8u9k6/e2LljoTLyTWO0c0nk=",
"owner": "yusdacra",
"repo": "nix-cargo-integration",
"rev": "e83f2598aecbe1114783ff9bdae0b85939de35a3",
"rev": "013350ad83767cf359882e900de381a624445947",
"type": "github"
},
"original": {

View File

@ -63,6 +63,30 @@
rustflags = ["-C", "link-arg=-fuse-ld=${lib.getExe pkgs.mold}"]
EOF
'';
pathsToIgnore = [
"flake.nix"
"flake.lock"
"nix"
"assets"
"README.md"
"CONTRIBUTING.md"
"CHANGELOG.md"
"CODE_OF_CONDUCT.md"
"clippy.toml"
];
ignorePaths = path: type: let
split = lib.splitString "/" path;
actual = lib.drop 4 split;
_path = lib.concatStringsSep "/" actual;
in
lib.all (n: ! (lib.hasPrefix n _path)) pathsToIgnore;
filteredSource = builtins.path {
name = "veloren-source";
path = toString ./.;
# filter out unnecessary paths
filter = ignorePaths;
};
in {
veloren-common = oldAttrs: {
# Disable `git-lfs` check here since we check it ourselves
@ -81,26 +105,7 @@
'';
};
veloren-voxygen = oldAttrs: {
src = builtins.path {
name = "veloren-source";
path = toString ./.;
# filter out unnecessary paths
filter = path: type:
lib.all
(n: builtins.baseNameOf path != n)
[
"flake.nix"
"flake.lock"
"nix"
"assets"
"README.md"
"CONTRIBUTING.md"
"CHANGELOG.md"
"CODE_OF_CONDUCT.md"
"clippy.toml"
"server-cli"
];
};
src = filteredSource;
buildInputs =
(oldAttrs.buildInputs or [])
@ -142,9 +147,25 @@
fi
'';
};
veloren-server-cli-deps = oldAttrs: {
doCheck = false;
postConfigure = ''
${oldAttrs.postConfigure or ""}
${configMoldLinker}
'';
};
veloren-server-cli = oldAttrs: {
nativeBuildInputs = (oldAttrs.nativeBuildInputs or []) ++ [pkgs.makeWrapper];
src = filteredSource;
VELOREN_USERDATA_STRATEGY = "system";
nativeBuildInputs = (oldAttrs.nativeBuildInputs or []) ++ [pkgs.makeWrapper];
postConfigure = ''
${oldAttrs.postConfigure or ""}
${configMoldLinker}
'';
postInstall = ''
${oldAttrs.postInstall or ""}
if [ -f $out/bin/veloren-server-cli ]; then