Having same script environment as devShell

I wonder if there is a way to have a script “wrapped” as if run inside a devShell.

I write bash script with writeShellApplication and use runtimeInputs to ensure that the PATH is correctly populated but other environment variables that are set by packages are not available to the script.
However these environment variables are available if these packages are put in a devShell.
How can the environment variables set by a package be available in a script in the same way as they are in a devShell ?

Maybe there is some hook called by devShell that I could call from the script itself ?

1 Like