Deps.edn read from environment variables


#1

Hey,

In deps.edn, is there a way to set parameters from system environment variables, for example:

{:paths ["src" "resources" "test" "classes"]
 :deps {nrepl/nrepl {:mvn/version "0.6.0"}
        cider/cider-nrepl {:mvn/version "0.21.1"}
        }
 :aliases {:run {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]" "-b" "HOSTNAME" "-p" "7888"]}}
}

Where HOSTNAME I would like to use my systems hostname, from environment variable $HOSTNAME. Is it possible to specify it using: (System/getenv “HOSTNAME”) or similar?


#2

No, there is no support for anything dynamic in EDN beyond a couple of built-in tagged literal readers (#inst and #uuid I believe).

It seems like it would be a nice enhancement for tools like nrepl.cmdline to accept flags that indicated values should be taken from the environment. At work we have a wrapper for starting REPLs so that we can get the port from somewhere other than the deps.edn :main-opts.