From dd68285d7949dd87b410fdd48c1332dc081e94ac Mon Sep 17 00:00:00 2001 From: Yusuf Bera Ertan Date: Fri, 11 Dec 2020 17:44:13 +0300 Subject: [PATCH] nix: fix veloren version string in game, remove obsolete utils --- nix/utils.nix | 29 ----------------------------- nix/veloren.nix | 15 +++++++++------ 2 files changed, 9 insertions(+), 35 deletions(-) diff --git a/nix/utils.nix b/nix/utils.nix index 2bd844affb..bea5c91bad 100644 --- a/nix/utils.nix +++ b/nix/utils.nix @@ -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"; - }; - } diff --git a/nix/veloren.nix b/nix/veloren.nix index 116c370df8..e15852148e 100644 --- a/nix/veloren.nix +++ b/nix/veloren.nix @@ -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}";