development-environmentnim-lang

Are there Nim 2.0 compiler environment variables like for Perl PERL5LIB or Python PYTHONPATH


I am running a programming multi language repository for different languages under ~/Libraries like

~/Libraries/Emacs
~/Libraries/Perl5
~/Libraries/Python311
...

under Debian Linux. Usually it is possible add/set and environment variable like PERL5LIB or PYTHONPATH to extend or define the module search path.

Question:

Are there similar features for the programming language Nim available?


Solution

  • You can specify where the Nim compiler searches for modules via the --path:<path> flag in a config.nims or nim.cfg file.

    When using Nimble, nimble will search for packages you have installed in ~/.nimble/pkgs2 - you can dump out the paths it uses via nimble setup - this will produce a nimble.paths file, and then an include to this file will be added to your config.nims similar to:

    # begin Nimble config (version 2)
    when withDir(thisDir(), system.fileExists("nimble.paths")):
      include "nimble.paths"
    # end Nimble config
    

    For atlas, it searches for paths in the deps folder relative to your project. The folder it searches can be configured, but atlas will produce a nim.cfg.