I'd like a new process to inherit the existing environment variables, as well as set my own.
I only see two options to set the environment variables within http://hackage.haskell.org/package/typed-process-0.2.6.0/docs/System-Process-Typed.html:
setEnv :: [(String, String)] -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderrSource
setEnvInherit :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr
I could manually get a list of all environment variables with System.Environment.getEnvironment
however it's documentation(http://hackage.haskell.org/package/base-4.12.0.0/docs/System-Environment.html#v:getEnvironment) mentions:
getEnvironment retrieves the entire environment as a list of (key,value) pairs.
If an environment entry does not contain an '=' character, the key is the whole entry and the value is the empty string.
Which seems a bit iffy.
Looking through the source there seems to be a data constructor that has the environment variables set in pcEnv :: !(Maybe [(String, String)])
- but this does not seem to be exported. Is there some means to modify this value?
One workaround can be done using the unix
package:
import System.Posix.Env (getEnvironment)
currentEnv <- getEnvironment
let totalEnv = currentEnv ++ [("KUBECONFIG","k8s.cfg")]