mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
build(nix): format nix files, fix git lfs error
This commit is contained in:
parent
b9586673d5
commit
a0b7446f58
130
flake.nix
130
flake.nix
@ -11,81 +11,83 @@
|
|||||||
app = "veloren-voxygen";
|
app = "veloren-voxygen";
|
||||||
};
|
};
|
||||||
overrides = {
|
overrides = {
|
||||||
crates = common: prev:
|
crates = common: prev: let
|
||||||
let
|
pkgs = common.pkgs;
|
||||||
pkgs = common.pkgs;
|
lib = common.lib;
|
||||||
lib = common.lib;
|
|
||||||
|
|
||||||
gitLfsCheckFile = ./assets/voxygen/background/bg_main.jpg;
|
gitLfsCheckFile = ./assets/voxygen/background/bg_main.jpg;
|
||||||
utils = import ./nix/utils.nix { inherit pkgs; };
|
utils = import ./nix/utils.nix {inherit pkgs;};
|
||||||
|
|
||||||
sourceInfo =
|
sourceInfo =
|
||||||
if inputs.self.sourceInfo ? rev
|
if inputs.self.sourceInfo ? rev
|
||||||
then inputs.self.sourceInfo // {
|
then
|
||||||
|
inputs.self.sourceInfo
|
||||||
|
// {
|
||||||
# Tag would have to be set manually for stable releases flake
|
# Tag would have to be set manually for stable releases flake
|
||||||
# because there's currently no way to get the tag via the interface.
|
# because there's currently no way to get the tag via the interface.
|
||||||
# tag = v0.9.0;
|
# tag = v0.9.0;
|
||||||
}
|
}
|
||||||
else (throw "Can't get revision because the git tree is dirty");
|
else (throw "Can't get revision because the git tree is dirty");
|
||||||
|
|
||||||
prettyRev = with sourceInfo; builtins.substring 0 8 rev + "/" + utils.dateTimeFormat lastModified;
|
prettyRev = with sourceInfo; builtins.substring 0 8 rev + "/" + utils.dateTimeFormat lastModified;
|
||||||
|
|
||||||
tag = with sourceInfo;
|
tag = with sourceInfo;
|
||||||
if sourceInfo ? tag
|
if sourceInfo ? tag
|
||||||
then sourceInfo.tag
|
then sourceInfo.tag
|
||||||
else "";
|
else "";
|
||||||
|
|
||||||
# If gitTag has a tag (meaning the commit we are on is a *release*), use
|
# 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
|
# it as version, else: just use the prettified hash we have, if we don't
|
||||||
# have it the build fails.
|
# have it the build fails.
|
||||||
# Must be in format f4987672/2020-12-10-12:00
|
# Must be in format f4987672/2020-12-10-12:00
|
||||||
version =
|
version =
|
||||||
if tag != "" then tag
|
if tag != ""
|
||||||
else if prettyRev != "" then prettyRev
|
then tag
|
||||||
else throw "Need a tag or pretty revision in order to determine version";
|
else if prettyRev != ""
|
||||||
|
then prettyRev
|
||||||
|
else throw "Need a tag or pretty revision in order to determine version";
|
||||||
|
|
||||||
veloren-assets = pkgs.runCommand "makeAssetsDir" { } ''
|
veloren-assets = pkgs.runCommand "makeAssetsDir" {} ''
|
||||||
mkdir $out
|
mkdir $out
|
||||||
ln -sf ${./assets} $out/assets
|
ln -sf ${./assets} $out/assets
|
||||||
'';
|
'';
|
||||||
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
|
# We have to include the command output here, otherwise Nix won't run it
|
||||||
# We have to include the command output here, otherwise Nix won't run it
|
DISABLE_GIT_LFS_CHECK = utils.isGitLfsSetup gitLfsCheckFile;
|
||||||
DISABLE_GIT_LFS_CHECK = utils.isGitLfsSetup gitLfsCheckFile;
|
# Declare env values here so that `common/build.rs` sees them
|
||||||
# Declare env values here so that `common/build.rs` sees them
|
NIX_GIT_HASH = prettyRev;
|
||||||
NIX_GIT_HASH = prettyRev;
|
NIX_GIT_TAG = tag;
|
||||||
NIX_GIT_TAG = tag;
|
|
||||||
};
|
|
||||||
veloren-voxygen = oldAttrs: {
|
|
||||||
nativeBuildInputs = (oldAttrs.nativeBuildInputs or []) ++ [ pkgs.makeWrapper ];
|
|
||||||
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: {
|
|
||||||
nativeBuildInputs = (oldAttrs.nativeBuildInputs or []) ++ [ pkgs.makeWrapper ];
|
|
||||||
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
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
veloren-voxygen = oldAttrs: {
|
||||||
|
nativeBuildInputs = (oldAttrs.nativeBuildInputs or []) ++ [pkgs.makeWrapper];
|
||||||
|
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: {
|
||||||
|
nativeBuildInputs = (oldAttrs.nativeBuildInputs or []) ++ [pkgs.makeWrapper];
|
||||||
|
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
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -3,4 +3,5 @@
|
|||||||
url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
|
url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
|
||||||
sha256 = "sha256:0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2";
|
sha256 = "sha256:0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2";
|
||||||
})
|
})
|
||||||
{ src = ../.; }).defaultNix
|
{src = ../.;})
|
||||||
|
.defaultNix
|
||||||
|
@ -3,4 +3,5 @@
|
|||||||
url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
|
url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
|
||||||
sha256 = "sha256:0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2";
|
sha256 = "sha256:0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2";
|
||||||
})
|
})
|
||||||
{ src = ../.; }).shellNix
|
{src = ../.;})
|
||||||
|
.shellNix
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
{ pkgs }: {
|
{pkgs}: {
|
||||||
isGitLfsSetup = checkFile:
|
isGitLfsSetup = checkFile: let
|
||||||
let
|
gitLfsCheckOutput = builtins.readFile (pkgs.runCommand "gitLfsCheck" {} ''
|
||||||
gitLfsCheckOutput =
|
result="$(${pkgs.file}/bin/file --mime-type ${checkFile})"
|
||||||
builtins.readFile (pkgs.runCommand "gitLfsCheck" { } ''
|
(if [ "$result" = "${checkFile}: image/jpeg" ]; then printf "0"; else printf "1"; fi) > $out
|
||||||
([ "$(${pkgs.file}/bin/file --mime-type ${checkFile})" = "${checkFile}: image/jpeg" ] && printf "0" || printf "1") > $out
|
'');
|
||||||
'');
|
in
|
||||||
in
|
if gitLfsCheckOutput == "0"
|
||||||
if gitLfsCheckOutput == "0" then
|
then true
|
||||||
true
|
|
||||||
else
|
else
|
||||||
abort ''
|
throw ''
|
||||||
Git Large File Storage (`git-lfs`) has not been set up correctly.
|
Git Large File Storage (`git-lfs`) has not been set up correctly.
|
||||||
Most common reasons:
|
Most common reasons:
|
||||||
- `git-lfs` was not installed before cloning this repository.
|
- `git-lfs` was not installed before cloning this repository.
|
||||||
@ -21,28 +20,47 @@
|
|||||||
'';
|
'';
|
||||||
|
|
||||||
# Format number of seconds in the Unix epoch as %Y-%m-%d-%H:%M.
|
# Format number of seconds in the Unix epoch as %Y-%m-%d-%H:%M.
|
||||||
dateTimeFormat = t:
|
dateTimeFormat = t: let
|
||||||
let
|
rem = x: y: x - x / y * y;
|
||||||
rem = x: y: x - x / y * y;
|
days = t / 86400;
|
||||||
days = t / 86400;
|
secondsInDay = rem t 86400;
|
||||||
secondsInDay = rem t 86400;
|
hours = secondsInDay / 3600;
|
||||||
hours = secondsInDay / 3600;
|
minutes = (rem secondsInDay 3600) / 60;
|
||||||
minutes = (rem secondsInDay 3600) / 60;
|
seconds = rem t 60;
|
||||||
seconds = rem t 60;
|
|
||||||
|
|
||||||
# Courtesy of https://stackoverflow.com/a/32158604.
|
# Courtesy of https://stackoverflow.com/a/32158604.
|
||||||
z = days + 719468;
|
z = days + 719468;
|
||||||
era = (if z >= 0 then z else z - 146096) / 146097;
|
era =
|
||||||
doe = z - era * 146097;
|
(
|
||||||
yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365;
|
if z >= 0
|
||||||
y = yoe + era * 400;
|
then z
|
||||||
doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
|
else z - 146096
|
||||||
mp = (5 * doy + 2) / 153;
|
)
|
||||||
d = doy - (153 * mp + 2) / 5 + 1;
|
/ 146097;
|
||||||
m = mp + (if mp < 10 then 3 else -9);
|
doe = z - era * 146097;
|
||||||
y' = y + (if m <= 2 then 1 else 0);
|
yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365;
|
||||||
|
y = yoe + era * 400;
|
||||||
|
doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
|
||||||
|
mp = (5 * doy + 2) / 153;
|
||||||
|
d = doy - (153 * mp + 2) / 5 + 1;
|
||||||
|
m =
|
||||||
|
mp
|
||||||
|
+ (
|
||||||
|
if mp < 10
|
||||||
|
then 3
|
||||||
|
else -9
|
||||||
|
);
|
||||||
|
y' =
|
||||||
|
y
|
||||||
|
+ (
|
||||||
|
if m <= 2
|
||||||
|
then 1
|
||||||
|
else 0
|
||||||
|
);
|
||||||
|
|
||||||
pad = s: if builtins.stringLength s < 2 then "0" + s else s;
|
pad = s:
|
||||||
in
|
if builtins.stringLength s < 2
|
||||||
"${toString y'}-${pad (toString m)}-${pad (toString d)}-${pad (toString hours)}:${pad (toString minutes)}";
|
then "0" + s
|
||||||
|
else s;
|
||||||
|
in "${toString y'}-${pad (toString m)}-${pad (toString d)}-${pad (toString hours)}:${pad (toString minutes)}";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user