From 5991d93bcb216c4cd5345296111fee7027be29cf Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Mon, 16 Sep 2024 18:00:44 -0500 Subject: [PATCH] fix: add version override for nix --- nix/flake.nix | 9 ++++++--- src/config.nim | 2 +- src/tsm.nim | 10 ++++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) 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 =