Say your project has a variable it expects to be set and you need to generate
the value for development.
This is a great use for the environment's shell hooks.
Let's set up a Flox environment using the postgresql_15
package in your environment:
$ floxinstallpostgresql_15
✅ 'postgresql_15' installed to environment postgres-example at /Users/youruser
Customize the environment's shell hook
Let's add some properties PostgreSQL needs to run properly in this
environment.
$ floxedit
Specifically, let's modify the hook section
and create a script.
All hook scripts inherit variables defined in the [vars] section of the manifest,
and environment variables set in the hook.on-activate script
are in turn inherited by the [profile] scripts that follow.
The hook.on-activate script is always run in a bash shell.
Save and exit your editor, you should see a confirmation after Flox
validates the environment.
✅ Environment successfully updated.
Test the environment
You can now flox activate the environment to see the result
of your hard work!
$ flox activate
✅ You are now using the environment postgres-example at /Users/youruser.
To stop using this environment, type 'exit'
Initializing postgresql database...
The files belonging to this database system will be owned by user "youruser".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
creating directory /Users/youruser/postgres_data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... America/New_York
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
Success. You can now start the database server using:
pg_ctl -D /Users/youruser/postgres_data -l logfile start