status-react/nix/lib/sanitizeVersion.nix
Anton Iakimov d5c1ecc104
nix: switch status-im config to env vars, cleanup
To help with #15595 changes, refactoring is required.
In this PR we switch from config to env vars.
Doing some cleanup meanwhile.
2023-08-07 14:50:36 +02:00

15 lines
551 B
Nix

{ lib }:
version:
let
# paths don't like slashes in them
dropSlashes = builtins.replaceStrings [ "/" ] [ "_" ];
# if version doesn't match this it's probably a commit, it's lax semver
versionRegex = "^v?[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+[[:alnum:]+_.-]*$";
in
if (builtins.match versionRegex version) != null
# Geth forces a 'v' prefix for all versions
then lib.removePrefix "v" (dropSlashes version)
# reduce metrics cardinality in Prometheus
else lib.traceValFn (_: "WARNING: Marking build version as 'develop'!") "develop"