forked from veloren/veloren
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
112 lines (104 loc) · 4.35 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
{
description = "Flake providing Veloren, a multiplayer voxel RPG written in Rust.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixCargoIntegration = {
url = "github:yusdacra/nix-cargo-integration";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs:
inputs.nixCargoIntegration.lib.makeOutputs {
root = ./.;
buildPlatform = "crate2nix";
defaultOutputs = {
package = "veloren-voxygen";
app = "veloren-voxygen";
};
overrides = {
build = common: prev: {
runTests = !prev.release && prev.runTests;
rootFeatures =
if prev.release && common.cargoPkg.name == "veloren-voxygen"
then [ "default-publish" ]
else prev.rootFeatures;
};
crateOverrides = common: prev:
let
pkgs = common.pkgs;
lib = common.lib;
gitLfsCheckFile = ./assets/voxygen/background/bg_main.jpg;
utils = import ./nix/utils.nix { inherit pkgs; };
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");
prettyRev = with sourceInfo; builtins.substring 0 8 rev + "/" + utils.dateTimeFormat lastModified;
tag = with sourceInfo;
if sourceInfo ? tag
then sourceInfo.tag
else "";
# 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";
veloren-assets = pkgs.runCommand "makeAssetsDir" { } ''
mkdir $out
ln -sf ${./assets} $out/assets
'';
in
{
# 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-voxygen-i18n = oldAttrs: {
crateBin = lib.filter (bin: bin.name != "i18n-check") 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" && bin.name != "recipe_graphviz") oldAttrs.crateBin;
};
veloren-voxygen = oldAttrs: {
VELOREN_USERDATA_STRATEGY = "system";
preConfigure = ''
substituteInPlace src/audio/soundcache.rs \
--replace \
"../../../assets/voxygen/audio/null.ogg" \
"${./assets/voxygen/audio/null.ogg}"
'';
postInstall = ''
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
'';
};
veloren-server-cli = oldAttrs: {
VELOREN_USERDATA_STRATEGY = "system";
postInstall = ''
if [ -f $out/bin/veloren-server-cli ]; then
wrapProgram $out/bin/veloren-server-cli --set VELOREN_ASSETS ${veloren-assets}
fi
'';
};
};
};
};
}