Nim: Config should be in its own directory

Created on 16 Aug 2018  路  8Comments  路  Source: nim-lang/Nim

https://github.com/nim-lang/Nim/issues/8599#issuecomment-412138212:

Nim should check for nim.cfg (et al.) in /etc/nim/nim.cfg instead of /etc/nim.cfg.

Path Handling

Most helpful comment

This is from Arch Wiki but it applies to most Linux distros.. Just as we used $XDG_CACHE_HOME/nim/ for Nim caches, use $XDG_CONFIG_HOME/nim/ in this case.

$XDG_CONFIG_HOME defaults to ~/.config.

All 8 comments

The canonical place on unix systems is ~/.config/FOO/FOO.cfg.

This is preferred because not all users have access to /etc/.., especially on work machines. But everyone can access their $HOME.

This is from Arch Wiki but it applies to most Linux distros.. Just as we used $XDG_CACHE_HOME/nim/ for Nim caches, use $XDG_CONFIG_HOME/nim/ in this case.

$XDG_CONFIG_HOME defaults to ~/.config.

@Araq: You are not using $XDG_CONFIG_HOME in that commit. Looks like few people agreed with that suggestion.

proc getUserConfigPath(filename: string): string =
  result = joinPath(getConfigDir(), filename)

Already was there and os.getConfigDir uses $XDG_CONFIG_HOME. There was nothing for me to do. And if it doesn't work, that's a different issue.

And if it doesn't work, that's a different issue.

OK. Thanks. So this deserves another issue. The "/nim/" needs to be appended in getUserConfigPath too it seems.

Already was there and os.getConfigDir uses $XDG_CONFIG_HOME. There was nothing for me to do. And if it doesn't work, that's a different issue.

getConfigDir was using XDG_CONFIG_DIR, which, as pointed by @kaushalmodi , should've been XDG_CONFIG_HOME ; will be fixed in @kaushalmodi 's https://github.com/nim-lang/Nim/pull/8662

@Araq Do we also have to fix our install scripts? Won't all the .cfg files still go to /etc/?

Edit: I fixed it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alaviss picture alaviss  路  3Comments

teroz picture teroz  路  3Comments

juancarlospaco picture juancarlospaco  路  3Comments

kobi2187 picture kobi2187  路  4Comments

SolitudeSF picture SolitudeSF  路  3Comments