diff --git a/flake.nix b/flake.nix index 98875fc8b7..e349b0303c 100644 --- a/flake.nix +++ b/flake.nix @@ -31,30 +31,6 @@ pkgs = common.pkgs; lib = pkgs.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 = - if sourceInfo ? tag - then sourceInfo.tag - else ""; - configMoldLinker = '' cat >>$CARGO_HOME/config.toml <= 0 then z else z - 146096) / 146097; + doe = z - era * 146097; + 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; +in "${toString y'}-${pad (toString m)}-${pad (toString d)}-${pad (toString hours)}:${pad (toString minutes)}" diff --git a/nix/utils.nix b/nix/utils.nix deleted file mode 100644 index d815af63b8..0000000000 --- a/nix/utils.nix +++ /dev/null @@ -1,66 +0,0 @@ -{pkgs}: { - isGitLfsSetup = checkFile: let - gitLfsCheckOutput = builtins.readFile (pkgs.runCommand "gitLfsCheck" {} '' - result="$(${pkgs.file}/bin/file --mime-type ${checkFile})" - (if [ "$result" = "${checkFile}: image/jpeg" ]; then printf "0"; else printf "1"; fi) > $out - ''); - in - if gitLfsCheckOutput == "0" - then true - else - throw '' - Git Large File Storage (`git-lfs`) has not been set up correctly. - Most common reasons: - - `git-lfs` was not installed before cloning this repository. - - This repository was not cloned from the primary GitLab mirror. - - The GitHub mirror does not support LFS. - See the book at https://book.veloren.net/ for details. - Run `nix-shell -p git git-lfs --run "git lfs install --local && git lfs fetch && git lfs checkout"` - or `nix shell nixpkgs#git-lfs nixpkgs#git -c sh -c "git lfs install --local && git lfs fetch && git lfs checkout"`. - ''; - - # Format number of seconds in the Unix epoch as %Y-%m-%d-%H:%M. - dateTimeFormat = t: let - rem = x: y: x - x / y * y; - days = t / 86400; - secondsInDay = rem t 86400; - hours = secondsInDay / 3600; - minutes = (rem secondsInDay 3600) / 60; - seconds = rem t 60; - - # Courtesy of https://stackoverflow.com/a/32158604. - z = days + 719468; - era = - ( - if z >= 0 - then z - else z - 146096 - ) - / 146097; - doe = z - era * 146097; - 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; - in "${toString y'}-${pad (toString m)}-${pad (toString d)}-${pad (toString hours)}:${pad (toString minutes)}"; -}