Change the default stdlib location for Linux packaging (#21328)

* Correctly evaluate the Nim prefix on Posix

* Document new packaging layout
This commit is contained in:
Gabriel Huber 2023-02-12 16:41:27 +01:00 • committed by GitHub
commit 6c15958a83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 12 deletions

View file

@ -717,22 +717,24 @@ proc getPrefixDir*(conf: ConfigRef): AbsoluteDir =
## clone or using installed nim, so that these exist: `result/doc/advopt.txt` ## clone or using installed nim, so that these exist: `result/doc/advopt.txt`
## and `result/lib/system.nim` ## and `result/lib/system.nim`
if not conf.prefixDir.isEmpty: result = conf.prefixDir if not conf.prefixDir.isEmpty: result = conf.prefixDir
else: result = AbsoluteDir splitPath(getAppDir()).head else:
let binParent = AbsoluteDir splitPath(getAppDir()).head
when defined(posix):
if binParent == AbsoluteDir"/usr":
result = AbsoluteDir"/usr/lib/nim"
elif binParent == AbsoluteDir"/usr/local":
result = AbsoluteDir"/usr/local/lib/nim"
else:
result = binParent
else:
result = binParent
proc setDefaultLibpath*(conf: ConfigRef) = proc setDefaultLibpath*(conf: ConfigRef) =
# set default value (can be overwritten): # set default value (can be overwritten):
if conf.libpath.isEmpty: if conf.libpath.isEmpty:
# choose default libpath: # choose default libpath:
var prefix = getPrefixDir(conf) var prefix = getPrefixDir(conf)
when defined(posix): conf.libpath = prefix / RelativeDir"lib"
if prefix == AbsoluteDir"/usr":
conf.libpath = AbsoluteDir"/usr/lib/nim"
elif prefix == AbsoluteDir"/usr/local":
conf.libpath = AbsoluteDir"/usr/local/lib/nim"
else:
conf.libpath = prefix / RelativeDir"lib"
else:
conf.libpath = prefix / RelativeDir"lib"
# Special rule to support other tools (nimble) which import the compiler # Special rule to support other tools (nimble) which import the compiler
# modules and make use of them. # modules and make use of them.

View file

@ -69,8 +69,11 @@ Hints on the build process:
What to install: What to install:
- The expected stdlib location is /usr/lib/nim - The expected stdlib location is `/usr/lib/nim/lib`, previously it was just `/usr/lib/nim`
- Global configuration files under /etc/nim - `nimdoc.css` and `nimdoc.cls` from the `doc` folder should go into `/usr/lib/nim/doc/`
- `tools/nim-gdb.py` should go into `/usr/lib/nim/tools/`
- `tools/dochack/dochack.js` should be installed to `/usr/lib/nim/tools/dochack/`
- Global configuration files under `/etc/nim`
- Optionally: manpages, documentation, shell completion - Optionally: manpages, documentation, shell completion
- When installing documentation, .idx files are not required - When installing documentation, .idx files are not required
- The "compiler" directory contains compiler sources and should not be part of the compiler binary package - The "compiler" directory contains compiler sources and should not be part of the compiler binary package