Source Edit

This module implements the basics for Linux distribution (“distro”) detection and the OS’s native package manager. Its primary purpose is to produce output for Nimble packages, like:

  1. To complete the installation, run:
  2. sudo apt-get install libblas-dev
  3. sudo apt-get install libvoodoo

The above output could be the result of a code snippet like:

  1. if detectOs(Ubuntu):
  2. foreignDep "lbiblas-dev"
  3. foreignDep "libvoodoo"

See packaging for hints on distributing Nim using OS packages.

Imports

strutils, osproc, envvars

Types

  1. Distribution {.pure.} = enum
  2. Windows, ## some version of Windows
  3. Posix, ## some POSIX system
  4. MacOSX, ## some version of OSX
  5. Linux, ## some version of Linux
  6. Ubuntu, Debian, Gentoo, Fedora, RedHat, OpenSUSE, Manjaro, Elementary, Zorin,
  7. CentOS, Deepin, ArchLinux, Artix, Antergos, PCLinuxOS, Mageia, LXLE, Solus,
  8. Lite, Slackware, Androidx86, Puppy, Peppermint, Tails, AntiX, Kali,
  9. SparkyLinux, Apricity, BlackLab, Bodhi, TrueOS, ArchBang, KaOS, WattOS,
  10. Korora, Simplicity, RemixOS, OpenMandriva, Netrunner, Alpine, BlackArch,
  11. Ultimate, Gecko, Parrot, KNOPPIX, GhostBSD, Sabayon, Salix, Q4OS, ClearOS,
  12. Container, ROSA, Zenwalk, Parabola, ChaletOS, BackBox, MXLinux, Vector, Maui,
  13. Qubes, RancherOS, Oracle, TinyCore, Robolinux, Trisquel, Voyager, Clonezilla,
  14. SteamOS, Absolute, NixOS, ## NixOS or a Nix build environment
  15. AUSTRUMI, Arya, Porteus, AVLinux, Elive, Bluestar, SliTaz, Solaris, Chakra,
  16. Wifislax, Scientific, ExTiX, Rockstor, GoboLinux, Void, BSD, FreeBSD, NetBSD,
  17. OpenBSD, DragonFlyBSD, Haiku

the list of known distributions Source Edit

Vars

  1. foreignDeps: seq[string] = @[]

Registered foreign deps. Source Edit

Consts

  1. LacksDevPackages = {Distribution.Gentoo, Distribution.Slackware,
  2. Distribution.ArchLinux, Distribution.Artix,
  3. Distribution.Antergos, Distribution.BlackArch,
  4. Distribution.ArchBang}

Source Edit

Procs

  1. proc echoForeignDeps() {....raises: [], tags: [], forbids: [].}

Writes the list of registered foreign deps to stdout. Source Edit

  1. proc foreignCmd(cmd: string; requiresSudo = false) {....raises: [], tags: [],
  2. forbids: [].}

Registers a foreign command to the internal list of commands that can be queried later. Source Edit

  1. proc foreignDep(foreignPackageName: string) {....raises: [], tags: [], forbids: [].}

Registers foreignPackageName to the internal list of foreign deps. It is your job to ensure that the package name is correct. Source Edit

  1. proc foreignDepInstallCmd(foreignPackageName: string): (string, bool) {.
  2. ...raises: [], tags: [], forbids: [].}

Returns the distro’s native command to install foreignPackageName and whether it requires root/admin rights. Source Edit

Templates

  1. template detectOs(d: untyped): bool

Distro/OS detection. For convenience, the required Distribution. qualifier is added to the enum value. Source Edit