2020-12-11 12:00:04 +00:00
|
|
|
{
|
|
|
|
description = "Flake providing Veloren, a multiplayer voxel RPG written in Rust.";
|
|
|
|
|
|
|
|
inputs = {
|
2021-04-16 15:09:51 +00:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
|
|
nixCargoIntegration = {
|
|
|
|
url = "github:yusdacra/nix-cargo-integration";
|
2021-03-23 13:02:47 +00:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
2020-12-11 12:00:04 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-04-16 15:45:38 +00:00
|
|
|
outputs = inputs:
|
|
|
|
let
|
|
|
|
output = inputs.nixCargoIntegration.lib.makeOutputs {
|
|
|
|
root = ./.;
|
2021-04-27 02:18:12 +00:00
|
|
|
buildPlatform = "crate2nix";
|
2021-04-16 15:45:38 +00:00
|
|
|
overrides = {
|
2021-04-27 02:18:12 +00:00
|
|
|
build = common: prev: {
|
|
|
|
runTests = !prev.release && prev.runTests;
|
2021-04-16 15:45:38 +00:00
|
|
|
};
|
2021-04-27 02:18:12 +00:00
|
|
|
common = prev:
|
2021-04-16 15:45:38 +00:00
|
|
|
let
|
2021-04-27 02:18:12 +00:00
|
|
|
pkgs = prev.pkgs;
|
|
|
|
lib = pkgs.lib;
|
|
|
|
|
|
|
|
gitLfsCheckFile = ./assets/voxygen/background/bg_main.png;
|
|
|
|
utils = import ./nix/utils.nix { inherit pkgs; };
|
|
|
|
|
2021-04-16 15:45:38 +00:00
|
|
|
sourceInfo =
|
|
|
|
if inputs.self.sourceInfo ? rev
|
|
|
|
then inputs.self.sourceInfo // {
|
|
|
|
# Tag would have to be set manually for stable releases flake
|
|
|
|
# because there's currently no way to get the tag via the interface.
|
|
|
|
# tag = v0.9.0;
|
|
|
|
}
|
|
|
|
else (throw "Can't get revision because the git tree is dirty");
|
2020-12-11 12:00:04 +00:00
|
|
|
|
2021-04-27 02:18:12 +00:00
|
|
|
prettyRev = with sourceInfo; builtins.substring 0 8 rev + "/" + utils.dateTimeFormat lastModified;
|
2021-04-16 15:09:51 +00:00
|
|
|
|
2021-04-16 15:45:38 +00:00
|
|
|
tag = with sourceInfo;
|
|
|
|
if sourceInfo ? tag
|
|
|
|
then sourceInfo.tag
|
|
|
|
else "";
|
2020-12-11 12:00:04 +00:00
|
|
|
|
2021-04-16 15:45:38 +00:00
|
|
|
# If gitTag has a tag (meaning the commit we are on is a *release*), use
|
|
|
|
# it as version, else: just use the prettified hash we have, if we don't
|
|
|
|
# have it the build fails.
|
|
|
|
# Must be in format f4987672/2020-12-10-12:00
|
|
|
|
version =
|
|
|
|
if tag != "" then tag
|
|
|
|
else if prettyRev != "" then prettyRev
|
|
|
|
else throw "Need a tag or pretty revision in order to determine version";
|
2020-12-11 12:00:04 +00:00
|
|
|
|
2021-04-16 15:45:38 +00:00
|
|
|
veloren-assets = pkgs.runCommand "makeAssetsDir" { } ''
|
|
|
|
mkdir $out
|
|
|
|
ln -sf ${./assets} $out/assets
|
|
|
|
'';
|
2021-03-23 13:02:47 +00:00
|
|
|
|
2021-04-27 02:18:12 +00:00
|
|
|
velorenOverride = common: oldAttr:
|
2021-04-16 15:45:38 +00:00
|
|
|
if common.cargoPkg.name == "veloren-voxygen"
|
|
|
|
then
|
|
|
|
{
|
2021-04-27 02:18:12 +00:00
|
|
|
VELOREN_USERDATA_STRATEGY = "system";
|
2021-04-16 15:45:38 +00:00
|
|
|
postInstall = ''
|
2021-04-27 02:18:12 +00:00
|
|
|
if [ -f $out/bin/veloren-voxygen ]; then
|
|
|
|
wrapProgram $out/bin/veloren-voxygen \
|
|
|
|
--set VELOREN_ASSETS ${veloren-assets} \
|
|
|
|
--set LD_LIBRARY_PATH ${lib.makeLibraryPath common.runtimeLibs}
|
|
|
|
fi
|
2021-04-16 15:45:38 +00:00
|
|
|
'';
|
2021-04-27 02:18:12 +00:00
|
|
|
patches = [
|
|
|
|
(import ./nix/nullOggPatch.nix { nullOgg = ./assets/voxygen/audio/null.ogg; inherit pkgs; })
|
|
|
|
];
|
2021-04-16 15:45:38 +00:00
|
|
|
}
|
|
|
|
else if common.cargoPkg.name == "veloren-server-cli"
|
|
|
|
then
|
|
|
|
{
|
2021-04-27 02:18:12 +00:00
|
|
|
VELOREN_USERDATA_STRATEGY = "system";
|
2021-04-16 15:45:38 +00:00
|
|
|
postInstall = ''
|
2021-04-27 02:18:12 +00:00
|
|
|
if [ -f $out/bin/veloren-server-cli ]; then
|
|
|
|
wrapProgram $out/bin/veloren-server-cli --set VELOREN_ASSETS ${veloren-assets}
|
|
|
|
fi
|
2021-04-16 15:45:38 +00:00
|
|
|
'';
|
|
|
|
}
|
|
|
|
else { };
|
|
|
|
in
|
|
|
|
{
|
2021-04-27 02:18:12 +00:00
|
|
|
crateOverrides = prev.crateOverrides // {
|
|
|
|
veloren-world = oldAttrs: {
|
|
|
|
crateBin = lib.filter (bin: bin.name != "chunk_compression_benchmarks") oldAttrs.crateBin;
|
|
|
|
};
|
|
|
|
veloren-client = oldAttrs: {
|
|
|
|
crateBin = lib.filter (bin: bin.name != "bot") oldAttrs.crateBin;
|
|
|
|
};
|
|
|
|
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
|
|
|
|
DISABLE_GIT_LFS_CHECK = utils.isGitLfsSetup gitLfsCheckFile;
|
|
|
|
# Declare env values here so that `common/build.rs` sees them
|
|
|
|
NIX_GIT_HASH = prettyRev;
|
|
|
|
NIX_GIT_TAG = tag;
|
|
|
|
crateBin = lib.filter (bin: bin.name != "csv_export" && bin.name != "csv_import") oldAttrs.crateBin;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
overrides = prev.overrides // {
|
|
|
|
mainBuild = velorenOverride;
|
2021-04-16 15:45:38 +00:00
|
|
|
};
|
|
|
|
};
|
2020-12-11 12:00:04 +00:00
|
|
|
};
|
2021-04-16 15:45:38 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
output // {
|
2021-04-27 02:18:12 +00:00
|
|
|
defaultApp = builtins.mapAttrs (_: apps: apps.veloren-voxygen) output.apps;
|
|
|
|
defaultPackage = builtins.mapAttrs (_: packages: packages.veloren-voxygen) output.packages;
|
2021-04-16 15:09:51 +00:00
|
|
|
};
|
2020-12-11 12:00:04 +00:00
|
|
|
}
|