diff --git a/nix/flake.nix b/nix/flake.nix index 4d22d31..f5ee04f 100644 --- a/nix/flake.nix +++ b/nix/flake.nix @@ -39,11 +39,14 @@ }; }); packages = forAllSystems (pkgs: { - tsm = pkgs.buildNimblePackage { + tsm = pkgs.buildNimblePackage rec { pname = "tsm"; - version = "2024.1001"; + version = "2024.1001-unstable"; src = ../.; - nimbleDepsHash = "sha256-ugu+bNCWukWSALzD0/i73d0O2kty85J824tHsmfWRDI="; + nimbleDepsHash = "sha256-1J0Wt/XjFiSN1MTfgg9tE5dY3GnXH/UgG3zCL19GgpU="; + nimFlags = [ + "-d:TsmVersion=v${version}" + ]; }; default = self.packages.${pkgs.system}.tsm; }); diff --git a/src/config.nim b/src/config.nim index 96d60a3..e5f0c34 100644 --- a/src/config.nim +++ b/src/config.nim @@ -1,4 +1,4 @@ -import std/[os, sequtils, strformat, strutils, parsecfg, tables] +import std/[os, sequtils, strformat, strutils, tables] import usu import term diff --git a/src/tsm.nim b/src/tsm.nim index 863cd25..b6aaeb2 100644 --- a/src/tsm.nim +++ b/src/tsm.nim @@ -14,10 +14,16 @@ proc tsm(open: bool = false) = else: tmux.attach project.name +proc getVersion(): string = + const tsmVersion {.strdefine.} = "unknown" + const gitVersion = staticExec "git describe --tags --always HEAD --match 'v*'" + when tsmVersion != "unknown": tsmVersion + else: gitVersion + + when isMainModule: import cligen - const vsn = staticExec "git describe --tags --always HEAD --match 'v*'" - clCfg.version = vsn + clCfg.version = getVersion() if clCfg.helpAttr.len == 0: clCfg.helpAttr =