nix: fix veloren version string in game, remove obsolete utils

This commit is contained in:
Yusuf Bera Ertan 2020-12-11 17:44:13 +03:00
parent fc7a3748c0
commit dd68285d79
No known key found for this signature in database
GPG Key ID: 1D8F8FAF2294D6EA
2 changed files with 9 additions and 35 deletions

View File

@ -1,5 +1,4 @@
{ pkgs }: {
isGitLfsSetup = checkFile:
let
gitLfsCheckOutput =
@ -44,32 +43,4 @@
pad = s: if builtins.stringLength s < 2 then "0" + s else s;
in
"${toString y'}-${pad (toString m)}-${pad (toString d)}-${pad (toString hours)}:${pad (toString minutes)}";
getGitInfo = dotGitPath:
let
makeGitCommand = subcommands: name:
builtins.readFile (pkgs.runCommand name { } ''
cd ${
# Only copy the `.git` directory to nix store, anything else is a waste.
builtins.path {
path = ../.git;
# Nix store path names don't accept names that start with a dot.
name = "dotgit-dir";
}
}
(${pkgs.git}/bin/git ${subcommands}) > $out
'');
in
{
gitHash = makeGitCommand
"log -n 1 --pretty=format:%h/%cd --date=format:%Y-%m-%d-%H:%M --abbrev=8"
"getGitHash";
gitTag =
# If the git command errors out we feed an empty string
makeGitCommand "describe --exact-match --tags HEAD || printf ''"
"getGitTag";
};
}

View File

@ -37,13 +37,19 @@ let
prettyRev = with sourceInfo;
if sourceInfo ? rev && sourceInfo ? lastModified
then builtins.substring 0 8 rev + "/" + utils.dateTimeFormat lastModified
else (utils.getGitInfo ../.git).gitHash;
else throw "Need revision + lastModified to determine version";
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 sourceInfo ? tag then sourceInfo.tag
if tag != "" then tag
else if prettyRev != "" then prettyRev
else throw "Need a tag or at least revision + lastModified in order to determine version";
# Sanitize version string since it might contain illegal characters for a Nix store path
@ -79,10 +85,7 @@ let
DISABLE_GIT_LFS_CHECK = utils.isGitLfsSetup common.gitLfsCheckFile;
# Declare env values here so that `common/build.rs` sees them
NIX_GIT_HASH = prettyRev;
# if we have a tag (meaning the commit we are on is a *release*),
# use it as version, else use the prettified hash we have;
# if we don't have it the build fails
NIX_GIT_TAG = version;
NIX_GIT_TAG = tag;
};
veloren-server-cli = _: {
name = "veloren-server-cli_${sanitizedVersion}";