ugexe / zef

Raku Module Management
Artistic License 2.0
207 stars 45 forks source link

Improve support for basic interpolation config.json #470

Closed codesections closed 1 year ago

codesections commented 2 years ago

The "StoreDir" and "TempDir" previously allowed for limited interpolation (limited to $*HOME and $*TMPDIR). This commit adds interpolation of $*XDG_DATA_HOME, $*XDG_CONFIG_HOME, and $*XDG_STATE_HOME with default values from the XDG spec.

It also extends the interpolation for the same values to "DefaultCUR", which also specifies a path.

(My use case for this PR is related to packaging Zef in an environment where Zef is installed system-wide but should use a DefaultCUR that's local to $USER – ideally, a subdirectory of $XDG_DATA_HOME)

ugexe commented 2 years ago

For all zef CLI and config options I want to have a corresponding ENV var, so ideally the DefaultCUR scenario would be replaced with something like setting ZEF_CONFIG_DEFAULTCUR and adding in Zef::CLI wherever $CONFIG<DefaultCUR> is used.

ugexe commented 2 years ago

I opened a PR that adds env variable options for setting these -- https://github.com/ugexe/zef/pull/472 -- which should allow you to do what you want in the immediate future (although it does required a second zef-specific env variable to be defined).

I'm still on the fence in regards to interpolating e.g. $*XDG_DATA_HOME because it don't actually exist. That would mean users not super familiar with raku (for instance os packagers) can't intuitively do raku -e 'say $*XDG_DATA_HOME' like they can with e.g. $*HOME. However I do agree improved integration with the xdg directory spec is a good thing.

2colours commented 1 year ago

@codesections do you think this PR turned unnecessary with ugexe's modifications? If so, I think it would be nice to close it to keep a clean (and transparent) sheet. If not, well, it needs to be updated... :)