This is, unfortunately, not possible at the moment with the way the template is
written. You can work around this, however, with the following macro:
import macros
import distros
macro findOS*(): Distribution =
var body = newNimNode(nnkStmtList)
# Mac is later in the enum than Posix, and
# Mac is technically posix, so this is needed
# to properly detect a Mac
body.add(
quote do:
if detectOS(MacOSX):
return Distribution.MacOSX
)
for distro in Distribution:
let distLit = ident($distro)
body.add(
quote do:
if detectOS(`distLit`):
return Distribution.`distLit`
)
result = quote do:
(proc (): Distribution = `body`)()
echo findOS()
Run