{"id":20405893,"url":"https://github.com/coldnew/config.clj","last_synced_at":"2025-10-17T09:24:02.372Z","repository":{"id":42578650,"uuid":"55894285","full_name":"coldnew/config.clj","owner":"coldnew","description":" Library for managing environment variables in Clojure using EDN configuration files.","archived":false,"fork":false,"pushed_at":"2016-04-11T03:01:31.000Z","size":83,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-15T11:56:47.422Z","etag":null,"topics":["clojure","config"],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coldnew.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-10T11:05:44.000Z","updated_at":"2017-06-20T16:30:01.000Z","dependencies_parsed_at":"2022-09-05T12:21:03.615Z","dependency_job_id":null,"html_url":"https://github.com/coldnew/config.clj","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldnew%2Fconfig.clj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldnew%2Fconfig.clj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldnew%2Fconfig.clj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldnew%2Fconfig.clj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coldnew","download_url":"https://codeload.github.com/coldnew/config.clj/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241950319,"owners_count":20047616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","config"],"created_at":"2024-11-15T05:13:47.481Z","updated_at":"2025-10-17T09:23:57.350Z","avatar_url":"https://github.com/coldnew.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Config.clj\n[![Circle CI](https://circleci.com/gh/coldnew/config.clj.svg?style=svg)](https://circleci.com/gh/coldnew/config.clj)\n[![License](http://img.shields.io/badge/license-Eclipse-blue.svg?style=flat)](https://www.eclipse.org/legal/epl-v10.html)\n\nSimple library for managing configuration using environment variables and EDN configuration files.\n\n[![Clojars Project](http://clojars.org/coldnew/config/latest-version.svg)](http://clojars.org/coldnew/config)\n\n[Latest codox API docs](https://coldnew.github.io/config.clj/).\n\n## Usage\n\nThis library will look for `config.edn` file on the classpath or file defined with `config` environment variable. The contents of this file will be merged with the environment variables found in `System/getenv` and `System/getProperties`.\n\nLet's create a simple testing project with following code, first add `config.edn` in `config/prod` and `config/dev` folder with setup like following:\n```clojure\n{:db \"jdbc:postgres://localhost/prod\"}\n```\nAnd build our `project.clj`\n```clojure\n(defproject config-test \"0.1.0-SNAPSHOT\"\n  :dependencies [[org.clojure/clojure \"1.8.0\"]\n                 [coldnew/config \"0.1.0-SNAPSHOT\"]]\n  :profiles {:prod {:resource-paths [\"config/prod\"]}\n             :dev  {:resource-paths [\"config/dev\"]}}\n  :main config-test.core)\n```\nNow you can add code in `src/config_test/core.clj` to print the variable we defined:\n```clojure\n(ns config-test.core\n  (:require [coldnew.config :refer [env conf]]))\n\n(defn -main []\n  (println (:db env))\n  (println (:db conf)))\n```\n\nThe application will print the `db` variable if it defined in environment variables or `config.edn` file. The different between `env` and `conf` function are the variables resolved order.\n\n[env](https://coldnew.github.io/config.clj/coldnew.config.html#var-env) is resolved in the following order, the variables found in later will replace those declared earlier:\n\n1. `config.edn` on the classpath.\n2. EDN file specified using the `config` environment variable.\n3. `.lein-env` file in the project directory.\n4. `.boot-env` file in the project directory.\n5. Environment vairables.\n6. Java system propertirs.\n\n[conf](https://coldnew.github.io/config.clj/coldnew.config.html#var-conf) is like `env`, but with different priority:\n\n1. `.lein-env` file in the project directory.\n2. `.boot-env` file in the project directory.\n3. Environment vairables.\n4. Java system propertirs.\n5. `config.edn` on the classpath.\n6. EDN file specified using the `config` environment variable.\n\nIf you want to use customize config.edn file, you can setup `config` environment variable.\n\nFor example, we can create a file called `custom-config.edn` that looks as follows:\n```clojure\n{:db \"jdbc:postgres://localhost/prod-custom\"}\n```\nThen we start the app and pass it the `config` environment variable pointing to the location of the file:\n```clojure\njava -Dconfig=\"custom-config.edn\" -jar target/config-test.jar\n=\u003e jdbc:postgres://localhost/prod-custom\n```\nor\n```clojure\nCONFIG=\"custon-config.edn\" java -jar target/config-test.jar\n=\u003e jdbc:postgres://localhost/prod-custom\n```\n\nIf you want your `config.edn` contains some function which need to be evaluated after load it, for example, your config.edn look like this:\n```clojure\n{:foo (System/getenv \"HOME\")}\n```\nyou can use [(enable-eval!)](https://coldnew.github.io/config.clj/coldnew.config.html#var-enable-eval.21) to make this library evaluate file content:\n```clojure\n(ns config-test.core\n  (:require [coldnew.config :as conf]))\n  \n(conf/enable-eval!)    ; Make coldnew.config evaluate the config after load it\n\n;; Following will print (System/getenv \"HOME\") result\n(println (conf/env :foo))\n(println (conf/conf :foo))\n```\n\n## Disclaimer\n\nThis library is based on [environ](https://github.com/weavejester/environ) and inspired by [yogthos/config](https://github.com/yogthos/config).\n\n## License\n\nCopyright © 2016 Yen-Chin, Lee \u003c\u003ccoldnew.tw@gmail.com\u003e\u003e\n\nDistributed under the Eclipse Public License either version 1.0 or any later version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoldnew%2Fconfig.clj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoldnew%2Fconfig.clj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoldnew%2Fconfig.clj/lists"}