nim.cfg based interop
Nimble requirements
- Add a new command called
nimble usecfg
- Creates/updates
nimbledeps.cfg
- Adds
--path
entries for all dependencies - Includes
--clearNimblePath
as well to remove any scanned packages already added - Uses
@include
innim.cfg
to loadnimbledeps.cfg
if it exists
- Creates/updates
- Nimble should detect if project is in
usecfg
mode- Check if
nimbledeps.cfg
exists and is being@include
'ed
- Check if
- Nimble functions like today if not in
usecfg
mode- User needs to opt in and use
nimble usecfg
once for project to get into this mode
- User needs to opt in and use
- When in
usecfg
mode- Commands like
nimble c
,nimble build
,nimble docs
should executeusecfg
before calling Nim - Above commands should no longer pass
--path
via CLI arguments to Nim - When saving to
nimbledeps.cfg
, Nimble should optimize if file really needs to be updated or if it is up to date
- Commands like
- Backwards compatibility
- Need to handle packages with existing
nim.cfg
without breakage- Need to handle cases wherenim.cfg
already has some--path
or--nimblePath
instances added by user - Need to ensure compatibility with existing
config.nims
- Need to handle packages with existing
- This change should work with standard
~/.nimble
as well as a custom--nimbleDir
- Need to evaluate impacts on other Nim tools that could potentially updatenim.cfg
or hard-code paths
Nim requirements
- Nim should support
$nimbleDir
substitution in--path
calls to enable relative paths - DONE$nimblePath
and$nimbleDir
both are supported- Handled differently than other $ substitutions since it is one to many
- Every
$nimbleDir
added to Nim will be added tosearchPaths
- If
$nimbleDir = ["$home/.nimble/pkgs", "$projectpath/nimbledeps/pkgs"]
--path:"$nimbleDir/pkg-0.1.0"
willsearchPaths.add(["$projectpath/nimbledeps/pkgs/pkg-0.1.0", "$home/.nimble/pkgs/pkg-0.1.0"])
- If
- nim-lang/Nim#12750
- Nim should support
@include
directive tonim.cfg
that allows including a separate file- Syntax
@include "path/to/file"
or@include varName
- Path should be processed with
pathSubs()
to allow$projectpath
style substitutions - If path specified does not exist, Nim will fail
- Behavior if older Nim loads
@include
- what happens
- Syntax
- Nim should support
@if fileExists("path/to/file)
or@if fileExists(varName)
- Allow optional
@include
of separate files -@if fileExists(fName): @include fName @end
- Behavior if older Nim loads
@if fileExists
- what happens
- Allow optional
nimble develop --recurse
Recursive develop
- the ability to actively develop a project and all its dependencies locally.
Nimble requirements
- Need a new
nimble develop --recurse
flag that sets all dependencies in a localnimble develop
mode- Main project is checked out with
nimble develop
- Each dependency is also checked out with
nimble develop
mode - Each dependency is stored in a project local
nimbledeps
directory and not the global $nimbleDir
- Main project is checked out with
--recurse
should work withusecfg
as well as standard Nimble behaviorusecfg
works well for--recurse
but forcing it would result innim.cfg
changes that user may not want to check in- Standard Nimble behavior can use
--nimbleDir
but that too will neednim.cfg
changes - Unclear at this point how standard Nimble behavior can coexist with
--recurse
- open to ideas
Updated
editcfg
tomodecfg
after discussion with @Araq since it suggests a change in Nimble behavior beyond a single command.