Use display for external deps and document this new feature.

This commit is contained in:
Dominik Picheta 2017-01-03 16:56:44 +00:00
commit 1c982a7e5f
3 changed files with 51 additions and 7 deletions

View file

@ -1,4 +1,4 @@
import ospaths, distros
import ospaths
template thisModuleFile: string = instantiationInfo(fullPaths = true).filename
when fileExists(thisModuleFile.parentDir / "src/nimblepkg/common.nim"):
@ -22,10 +22,12 @@ srcDir = "src"
requires "nim >= 0.13.0", "compiler#head"
if detectOs(Ubuntu):
foreignDep "libssl-dev"
elif detectOs(MacOSX):
foreignDep "openssl"
when defined(nimdistros):
import distros
if detectOs(Ubuntu):
foreignDep "libssl-dev"
else:
foreignDep "openssl"
task test, "Run the Nimble tester!":
withDir "tests":

View file

@ -31,6 +31,7 @@ Interested in learning **how to create a package**? Skip directly to that sectio
- [Binary packages](#binary-packages)
- [Hybrids](#hybrids)
- [Dependencies](#dependencies)
- [External dependencies](#external-dependencies)
- [Nim compiler](#nim-compiler)
- [Versions](#versions)
- [Releasing a new version](#releasing-a-new-version)
@ -575,6 +576,44 @@ This is done with the ``#`` character,
for example: ``jester#head``. Which will make your package depend on the
latest commit of Jester.
#### External dependencies
**Warning:** This feature is brand new in Nimble v0.8.0. Breaking changes
related to it are more likely to be introduced than for any other Nimble
features.
Starting with Nimble v0.8.0, you can now specify external dependencies. These
are dependencies which are not managed by Nimble and can only be installed via
your system's package manager or downloaded manually via the internet.
As an example, to specify a dependency on openssl you may put this in your
.nimble file:
```nim
when defined(nimdistros):
import distros
if detectOs(Ubuntu):
foreignDep "libssl-dev"
else:
foreignDep "openssl"
```
The ``when`` branch is important to support installation using older versions
of Nimble.
The [distros module](nim-lang.org/docs/distros.html) in Nim's
standard library contains a list of all the supported Operating Systems and
Linux distributions.
With this inside your .nimble file, Nimble will output the following after
installing your package (on macOS):
```
Hint: This package requires some external dependencies.
Hint: To install them you may be able to run:
Hint: sudo brew install openssl
```
### Nim compiler
The Nim compiler cannot read .nimble files. Its knowledge of Nimble is

View file

@ -995,9 +995,12 @@ proc doAction(options: Options) =
if options.action.packages.len == 0:
nimScriptHint(pkgInfo)
if pkgInfo.foreignDeps.len > 0:
echo("To finish the installation, run: ")
display("Hint:", "This package requires some external dependencies.",
Warning, HighPriority)
display("Hint:", "To install them you may be able to run:",
Warning, HighPriority)
for i in 0..<pkgInfo.foreignDeps.len:
echo(pkgInfo.foreignDeps[i])
display("Hint:", " " & pkgInfo.foreignDeps[i], Warning, HighPriority)
of actionUninstall:
uninstall(options)
of actionSearch: