I am new to Nim, but have used Python for the last couple of years primarily for Network uses (capturing configurations, configuring and staging devices, etc.). Not a Python expert by even the broadest of imaginations, but I am comfortable with it.
I wanted to pick up a systems type language to expand my horizons and of course Nim caught my attention. That out of the way...
I have my text editor set up and was wanting to set up a simple project environment and reading How I start, though quite old it was at least something to reference. I am wondering, however, if I need to install packages from Nimble, how do I keep those packages from polluting the global space in the way Python would use virtualenv? Or is that even a consideration with Nim?
I guess, in short, I am looking for some guidance on how to set up a project environment so I can start following some tutorials and write some code examples, etc. Anyway, thank you in advance.
If you wish to use nimble, it does install your dependencies into a nimbledeps directory if it is present in the folder that contains your .nimble file (docs)
You could also play around with atlas which is positioning itself as an alternative. It has the concept of workspaces, though from the docs I can't quite make out whether it supports the usecase of "one workspace per project" so that each project has its own dependencies.
@Araq and @Isofruit, thank you both for your replies. I will look at Atlas and try to set it up. Do I understand correctly, then, that if you wanted to remove a dependency, you'd just delete it from the nimbledeps folder?
I think I am over complicating this but just thinking along the lines of version incompatibilities/collisions where different projects may be using different dependency versions. Forgive me if I am off base here, just trying to work my way through getting started.
I think all I need for most network related stuff I would do would be ssh2 and tcping. I think the standard library had some imports available that would deal with IP addresses and subnetting.
By having a nimbledeps dir, any project-specific command you run via nimble (such as nimble install, nimble run, nimble <custom_task>) will make use only of those dependencies (and additional ones you might have specified via flag) and nothing from your global .nimble directory.
Removing a dependency in the Atlas case I can't be certain, but generally I'd claim it is both removing the corresponding "requires" statement from your <project>.nimble file and deleting the dependency from that local folder (otherwise it might just get redownloaded). Though deleting the dependency from the local folder likely isn't necessary - you'd just save yourself the disk space.
Thank you sir! In that case, I'll just start with the nimbledeps and explore Atlas as I get more comfortable with things and know better what to look for.
If I may be so bold as to impose one last time, is it the generally accepted practice to set up the project folder running nimble init <project name> as indicated in the How I Start? Or is there some other perhaps better way?
Sorry for the deluge of questions.
I am in the same situation (coming from Go and a little bit of Python) and trying to start a simple project with nimble and prologue.
I set up a new directory 'prologue_playgrund' and inside of it i ran 'nimble init', selected binary as project type.
in the src/prologue_playground.nim I pasted:
import prologue
proc hello*(ctx: Context) {.async.} =
resp "<h1>Hello, Prologue!</h1>"
let app = newApp()
app.addRoute("/", hello)
app.run()
When running nimble run in the project root folder, I am getting the message: 'Error: cannot open file: prologue'.
Using the same code outside the project folder with 'nim c -r prologue_playground.nim' works as expected. Am I using nimble in a wrong way? Or do I have to put the dependencies manually in the .nimble file (I thought that is managed by the 'nimble install' like in Go)? Is nimble not used as a dependency management for projects?
Thanks a lot.