idris-lang / Idris2

A purely functional programming language with first class types
https://idris-lang.org/
Other
2.53k stars 378 forks source link

[ new ] Support for dumping a package's install location #3381

Closed mattpolzin closed 2 months ago

mattpolzin commented 2 months ago

Description

Historically I have hard coded assumptions about where Idris will install a package when idris2 --install is called. This works, but it's fragile, inconvenient, and far from obvious.

See, for example, this snippet from one of my C support library Makefiles:

PACKAGE_INSTALLDIR = `${IDRIS} --libdir`
INSTALLDIR = ${PACKAGE_INSTALLDIR}/ncurses-idris-${TARGET_VERSION}/lib

This PR introduces idris2 --dump-installdir which could make the above Makefile snippet much more reasonable:

DESTDIR = `${IDRIS} --dump-installdir --find-ipkg`
INSTALLDIR = ${DESTDIR}/lib

While I was adding --dump-installdir anyway, I also used it in the existing Nix buildIdris function to better support a "Pack-ism" where C support libraries are installed to the ./lib folder and Pack takes care of the rest. Now buildIdris also takes care of the rest.

Should this change go in the CHANGELOG?

gallais commented 2 months ago

Can we get a test of this command-line option so that we are forced to think about any changes affecting the printed string?

mattpolzin commented 2 months ago

Yeah, that’s a good call. I’ll add a test later today.