mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
build(nix): refactor flake with new nci
This commit is contained in:
parent
558f6be222
commit
960aac307d
@ -90,11 +90,11 @@
|
|||||||
"rust-overlay": "rust-overlay"
|
"rust-overlay": "rust-overlay"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1662177071,
|
"lastModified": 1662234098,
|
||||||
"narHash": "sha256-x6XF//RdZlw81tFAYM1TkjY+iQIpyMCWZ46r9o4wVQY=",
|
"narHash": "sha256-zl52sS2Jr2lOguuC4DpLYLU+JYFzjV0xaFycwllKFAE=",
|
||||||
"owner": "yusdacra",
|
"owner": "yusdacra",
|
||||||
"repo": "nix-cargo-integration",
|
"repo": "nix-cargo-integration",
|
||||||
"rev": "65270dea87bb82fc02102a15221677eea237680e",
|
"rev": "3066def381d38288a9ecdf9a620fbb756c588ec1",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
211
flake.nix
211
flake.nix
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
outputs = inputs: let
|
outputs = inputs: let
|
||||||
lib = inputs.nci.inputs.nixpkgs.lib;
|
lib = inputs.nci.inputs.nixpkgs.lib;
|
||||||
|
|
||||||
git = let
|
git = let
|
||||||
sourceInfo = inputs.self.sourceInfo;
|
sourceInfo = inputs.self.sourceInfo;
|
||||||
dateTimeFormat = import ./nix/dateTimeFormat.nix;
|
dateTimeFormat = import ./nix/dateTimeFormat.nix;
|
||||||
@ -14,40 +15,8 @@
|
|||||||
prettyRev = shortRev + "/" + dateTime;
|
prettyRev = shortRev + "/" + dateTime;
|
||||||
tag = "";
|
tag = "";
|
||||||
};
|
};
|
||||||
outputs = inputs.nci.lib.makeOutputs {
|
|
||||||
root = ./.;
|
|
||||||
defaultOutputs = {
|
|
||||||
package = "veloren-voxygen";
|
|
||||||
app = "veloren-voxygen";
|
|
||||||
};
|
|
||||||
perCrateOverrides = {
|
|
||||||
veloren-voxygen = {
|
|
||||||
packageMetadata = _: {
|
|
||||||
features = rec {
|
|
||||||
release = ["default-publish"];
|
|
||||||
debug = release;
|
|
||||||
test = release;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
overrides = {
|
|
||||||
cCompiler = common: {
|
|
||||||
cCompiler = common.pkgs.clang;
|
|
||||||
useCCompilerBintools = true;
|
|
||||||
};
|
|
||||||
crates = common: prev: let
|
|
||||||
pkgs = common.pkgs;
|
|
||||||
lib = pkgs.lib;
|
|
||||||
|
|
||||||
configMoldLinker = ''
|
|
||||||
cat >>$CARGO_HOME/config.toml <<EOF
|
|
||||||
[target.x86_64-unknown-linux-gnu]
|
|
||||||
linker = "clang"
|
|
||||||
rustflags = ["-C", "link-arg=-fuse-ld=${lib.getExe pkgs.mold}"]
|
|
||||||
EOF
|
|
||||||
'';
|
|
||||||
|
|
||||||
|
filteredSource = let
|
||||||
pathsToIgnore = [
|
pathsToIgnore = [
|
||||||
"flake.nix"
|
"flake.nix"
|
||||||
"flake.lock"
|
"flake.lock"
|
||||||
@ -65,12 +34,101 @@
|
|||||||
_path = lib.concatStringsSep "/" actual;
|
_path = lib.concatStringsSep "/" actual;
|
||||||
in
|
in
|
||||||
lib.all (n: ! (lib.hasPrefix n _path)) pathsToIgnore;
|
lib.all (n: ! (lib.hasPrefix n _path)) pathsToIgnore;
|
||||||
filteredSource = builtins.path {
|
in
|
||||||
|
builtins.path {
|
||||||
name = "veloren-source";
|
name = "veloren-source";
|
||||||
path = toString ./.;
|
path = toString ./.;
|
||||||
# filter out unnecessary paths
|
# filter out unnecessary paths
|
||||||
filter = ignorePaths;
|
filter = ignorePaths;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wrapWithAssets = common: _: old: let
|
||||||
|
pkgs = common.pkgs;
|
||||||
|
runtimeLibs = with pkgs; [
|
||||||
|
xorg.libX11
|
||||||
|
xorg.libXi
|
||||||
|
xorg.libxcb
|
||||||
|
xorg.libXcursor
|
||||||
|
xorg.libXrandr
|
||||||
|
libxkbcommon
|
||||||
|
shaderc.lib
|
||||||
|
udev
|
||||||
|
alsa-lib
|
||||||
|
vulkan-loader
|
||||||
|
];
|
||||||
|
assets = pkgs.runCommand "veloren-assets" {} ''
|
||||||
|
mkdir $out
|
||||||
|
ln -sf ${./assets} $out/assets
|
||||||
|
# check if LFS was setup properly
|
||||||
|
checkFile="$out/assets/voxygen/background/bg_main.jpg"
|
||||||
|
result="$(${pkgs.file}/bin/file --mime-type $checkFile)"
|
||||||
|
if [ "$result" = "$checkFile: image/jpeg" ]; then
|
||||||
|
echo "Git LFS seems to be setup properly."
|
||||||
|
else
|
||||||
|
echo "
|
||||||
|
Git Large File Storage (git-lfs) has not been set up correctly.
|
||||||
|
Most common reasons:
|
||||||
|
- git-lfs was not installed before cloning this repository.
|
||||||
|
- This repository was not cloned from the primary GitLab mirror.
|
||||||
|
- The GitHub mirror does not support LFS.
|
||||||
|
See the book at https://book.veloren.net/ for details.
|
||||||
|
Run 'nix-shell -p git git-lfs --run \"git lfs install --local && git lfs fetch && git lfs checkout\"'
|
||||||
|
or 'nix shell nixpkgs#git-lfs nixpkgs#git -c sh -c \"git lfs install --local && git lfs fetch && git lfs checkout\"'.
|
||||||
|
"
|
||||||
|
false
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
wrapped =
|
||||||
|
common.internal.nci-pkgs.utils.wrapDerivation old
|
||||||
|
{nativeBuildInputs = [pkgs.makeWrapper];}
|
||||||
|
''
|
||||||
|
rm -rf $out/bin
|
||||||
|
mkdir $out/bin
|
||||||
|
ln -sf ${old}/bin/* $out/bin/
|
||||||
|
wrapProgram $out/bin/* \
|
||||||
|
${lib.optionalString (old.pname == "veloren-voxygen") "--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath runtimeLibs}"} \
|
||||||
|
--set VELOREN_ASSETS ${assets} \
|
||||||
|
--set VELOREN_GIT_VERSION "${git.prettyRev}" \
|
||||||
|
--set VELOREN_GIT_TAG "${git.tag}"
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
wrapped;
|
||||||
|
in
|
||||||
|
inputs.nci.lib.makeOutputs {
|
||||||
|
root = ./.;
|
||||||
|
defaultOutputs = {
|
||||||
|
package = "veloren-voxygen";
|
||||||
|
app = "veloren-voxygen";
|
||||||
|
};
|
||||||
|
perCrateOverrides = {
|
||||||
|
veloren-voxygen = {
|
||||||
|
packageMetadata = _: {
|
||||||
|
features = rec {
|
||||||
|
release = ["default-publish"];
|
||||||
|
debug = release;
|
||||||
|
test = release;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
wrapper = wrapWithAssets;
|
||||||
|
};
|
||||||
|
veloren-server-cli.wrapper = wrapWithAssets;
|
||||||
|
};
|
||||||
|
overrides = {
|
||||||
|
cCompiler = common: {
|
||||||
|
cCompiler = common.pkgs.clang;
|
||||||
|
useCCompilerBintools = true;
|
||||||
|
};
|
||||||
|
crates = common: prev: let
|
||||||
|
pkgs = common.pkgs;
|
||||||
|
lib = pkgs.lib;
|
||||||
|
|
||||||
|
configMoldLinker = ''
|
||||||
|
cat >>$CARGO_HOME/config.toml <<EOF
|
||||||
|
[target.x86_64-unknown-linux-gnu]
|
||||||
|
linker = "clang"
|
||||||
|
rustflags = ["-C", "link-arg=-fuse-ld=${lib.getExe pkgs.mold}"]
|
||||||
|
EOF
|
||||||
|
'';
|
||||||
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
|
||||||
@ -148,89 +206,4 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
wrapWithAssets = system: old: let
|
|
||||||
pkgs = inputs.nci.inputs.nixpkgs.legacyPackages.${system};
|
|
||||||
runtimeLibs = with pkgs; [
|
|
||||||
xorg.libX11
|
|
||||||
xorg.libXcursor
|
|
||||||
xorg.libXrandr
|
|
||||||
xorg.libXi
|
|
||||||
xorg.libxcb
|
|
||||||
libxkbcommon
|
|
||||||
vulkan-loader
|
|
||||||
vulkan-extension-layer
|
|
||||||
shaderc.lib
|
|
||||||
udev
|
|
||||||
alsa-lib
|
|
||||||
];
|
|
||||||
assets = pkgs.runCommand "veloren-assets" {} ''
|
|
||||||
mkdir $out
|
|
||||||
ln -sf ${./assets} $out/assets
|
|
||||||
# check if LFS was setup properly
|
|
||||||
checkFile="$out/assets/voxygen/background/bg_main.jpg"
|
|
||||||
result="$(${pkgs.file}/bin/file --mime-type $checkFile)"
|
|
||||||
if [ "$result" = "$checkFile: image/jpeg" ]; then
|
|
||||||
echo "Git LFS seems to be setup properly."
|
|
||||||
else
|
|
||||||
echo "
|
|
||||||
Git Large File Storage (git-lfs) has not been set up correctly.
|
|
||||||
Most common reasons:
|
|
||||||
- git-lfs was not installed before cloning this repository.
|
|
||||||
- This repository was not cloned from the primary GitLab mirror.
|
|
||||||
- The GitHub mirror does not support LFS.
|
|
||||||
See the book at https://book.veloren.net/ for details.
|
|
||||||
Run 'nix-shell -p git git-lfs --run \"git lfs install --local && git lfs fetch && git lfs checkout\"'
|
|
||||||
or 'nix shell nixpkgs#git-lfs nixpkgs#git -c sh -c \"git lfs install --local && git lfs fetch && git lfs checkout\"'.
|
|
||||||
"
|
|
||||||
false
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
wrapped =
|
|
||||||
pkgs.runCommand "${old.name}-wrapped"
|
|
||||||
{
|
|
||||||
inherit (old) pname version meta;
|
|
||||||
nativeBuildInputs = [pkgs.makeWrapper];
|
|
||||||
}
|
|
||||||
''
|
|
||||||
mkdir -p $out
|
|
||||||
ln -sf ${old}/* $out/
|
|
||||||
rm -rf $out/bin
|
|
||||||
mkdir $out/bin
|
|
||||||
ln -sf ${old}/bin/* $out/bin/
|
|
||||||
wrapProgram $out/bin/* \
|
|
||||||
${lib.optionalString (old.pname == "veloren-voxygen") "--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath runtimeLibs}"} \
|
|
||||||
--set VELOREN_ASSETS ${assets} \
|
|
||||||
--set VELOREN_GIT_VERSION "${git.prettyRev}" \
|
|
||||||
--set VELOREN_GIT_TAG "${git.tag}"
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
wrapped;
|
|
||||||
in
|
|
||||||
outputs
|
|
||||||
// rec {
|
|
||||||
apps =
|
|
||||||
lib.mapAttrs
|
|
||||||
(system: _: rec {
|
|
||||||
default = veloren;
|
|
||||||
veloren = {
|
|
||||||
type = "app";
|
|
||||||
program = lib.getExe packages.${system}.veloren-voxygen;
|
|
||||||
};
|
|
||||||
veloren-server = {
|
|
||||||
type = "app";
|
|
||||||
program = lib.getExe packages.${system}.veloren-server-cli;
|
|
||||||
};
|
|
||||||
})
|
|
||||||
outputs.apps;
|
|
||||||
packages =
|
|
||||||
lib.mapAttrs
|
|
||||||
(system: pkgs: rec {
|
|
||||||
default = veloren-voxygen;
|
|
||||||
veloren-voxygen = wrapWithAssets system pkgs.veloren-voxygen;
|
|
||||||
veloren-voxygen-debug = wrapWithAssets system pkgs.veloren-voxygen-debug;
|
|
||||||
veloren-server-cli = wrapWithAssets system pkgs.veloren-server-cli;
|
|
||||||
veloren-server-cli-debug = wrapWithAssets system pkgs.veloren-server-cli-debug;
|
|
||||||
})
|
|
||||||
outputs.packages;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user