On 2025-06-04 22:14, Rutherther wrote:

Is there a recommended way for a package to set environment variables
that should persist after install?

The only way to do that is search paths. Those point to a folder in the
profile you install to. No other mechanism is supported for packages to
'set' something in user's environment. See the search-paths and
native-search-paths fields of packages.

Thanks. Looks like search-paths could work in this case.

You haven't shared much details, so just a heads up - keep in mind that
it's much better to wrap programs (script setting env vars that runs the
program) rather than to export environment to user if that is possible.

In more detail, i'm using metaphlan for metagenomic profiling of microboime data which requires some large databases (generally 10~100s of GB) installed. the program has a command line arg to download tar & md5, install databases (which can vary depending on input) & check integrity.

The database install doesn't work without modification, since the default path in the store is read only. The path can be set by an env var or an arg at runtime.

There appear to be a few ways around this i can see
- set a VAR in the user profile (which is the way i'm working currently)
- use --db_dir PATH for every invocation (fragile)
- make a package definition for each db and add paths somewhere?
- patch the --install command to print a msg about manual setup
- wrap the command as suggested above and set VAR for db path

The option of creating package definitions for each db (or single package with multiple outputs?) seems most guix-like but i'm unclear about how metaphlan could easily find the data installed by other guix packages?

Wrapping the command in a shell script that sets VAR & calls metaphlan could work, is there a simple example somewhere in the guix tree?

regards,
nik





Reply via email to