diff --git a/nimble.nimble b/nimble.nimble index 7617ee7..68b439b 100644 --- a/nimble.nimble +++ b/nimble.nimble @@ -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": diff --git a/readme.markdown b/readme.markdown index 2c85498..97a28d5 100644 --- a/readme.markdown +++ b/readme.markdown @@ -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 diff --git a/src/nimble.nim b/src/nimble.nim index 82c1702..6889fbe 100644 --- a/src/nimble.nim +++ b/src/nimble.nim @@ -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..