{"id":13788414,"url":"https://github.com/yogthos/config","last_synced_at":"2025-12-12T01:19:13.120Z","repository":{"id":43369645,"uuid":"20979786","full_name":"yogthos/config","owner":"yogthos","description":"Library for managing environment variables in Clojure using EDN configuration files","archived":false,"fork":false,"pushed_at":"2024-10-06T19:31:13.000Z","size":49,"stargazers_count":165,"open_issues_count":1,"forks_count":15,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-10-21T18:44:19.465Z","etag":null,"topics":["clojure","config","configparser","configuration-management"],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yogthos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"yogthos"}},"created_at":"2014-06-18T22:12:05.000Z","updated_at":"2025-07-25T10:17:02.000Z","dependencies_parsed_at":"2024-11-13T04:01:00.869Z","dependency_job_id":"6edc0969-2332-401a-9680-0c004f0ef452","html_url":"https://github.com/yogthos/config","commit_stats":{"total_commits":53,"total_committers":11,"mean_commits":4.818181818181818,"dds":0.2075471698113207,"last_synced_commit":"e9076ad18fce0b24c72d317dd23c43766dd95c8c"},"previous_names":["yogthos/edn-config","luminus-framework/config"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yogthos/config","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yogthos%2Fconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yogthos%2Fconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yogthos%2Fconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yogthos%2Fconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yogthos","download_url":"https://codeload.github.com/yogthos/config/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yogthos%2Fconfig/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27673140,"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","status":"online","status_checked_at":"2025-12-11T02:00:11.302Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","configparser","configuration-management"],"created_at":"2024-08-03T21:00:45.419Z","updated_at":"2025-12-12T01:19:13.079Z","avatar_url":"https://github.com/yogthos.png","language":"Clojure","funding_links":["https://github.com/sponsors/yogthos"],"categories":["config"],"sub_categories":[],"readme":"## `yogthos/config`\n\nA library for managing configuration using environment variables and EDN configuration files.\n\nThe configuration is resolved in the following order, the variables found in later configurations will replace those declared earlier:\n\n1. `config.edn` on the classpath\n2. `.lein-env` file in the project directory\n3. `.boot-env` file in the project directory\n4. EDN file specified using the `config` environment variable\n5. Environment variables\n6. Java System properties\n\nThe library parses configuration keys into Clojure keywords with names lowercased, then `_` and `.` characters converted to dashes, e.g:\n\n* `foo_bar` -\u003e `foo-bar`\n* `Foo_bar` -\u003e `foo-bar`\n* `Foo.BAR` -\u003e `foo-bar`\n\nnamespaced keys can be declared using `__`:\n\n* `db__spec` -\u003e `db/spec`\n\nThe library uses ClojureScript-like substitution for special signs:\n\n* `FOO_QMARK_` -\u003e `foo?`\n* `FOO_BANG_` -\u003e `foo!`\n* `FOO_PLUS_` -\u003e `foo+`\n* `FOO_GT_` -\u003e `foo\u003e`\n* `FOO_LT_` -\u003e `foo\u003c`\n* `FOO_EQ_` -\u003e `foo=`\n* `FOO_STAR_` -\u003e `foo*`\n\n\nThe values are parsed using the following strategy:\n\n1. `[0-9]+` -\u003e number\n2. `^(true|false)$` -\u003e boolean\n3. `\\w+` -\u003e string\n4. try parse as EDN, and return the original value as the default\n\nfollowing environment variables:\n\n```bash\n* BOOL=true\n* text=\"true\"\n* number=15\n* quoted-number=\"12\"\n* db__spec=\"jdbc:sqlite:myapp_dev.db\"\n* edn_string=\"{:foo :bar :baz [1 2 \\\"foo\\\"]}\"\n* unparsed.text=\"some text here\"\n* WITH_BANG_=\":bang!\"\n* WITH_PLUS_=\":plus+\"\n```\n\nare translated as:\n\n``` clojure\n* :bool          true,\n* :text          \"true\",\n* :number        15,\n* :quoted-number \"12\",\n* :db/spec       \"jdbc:sqlite:myapp_dev.db\"\n* :edn-string    {:foo :bar, :baz [1 2 \"foo\"]},\n* :unparsed-text \"some text here\"\n* :with!         :bang!\n* :with+         :plus+\n```\n## Installation\n\nInclude the following dependency in your `project.clj` file:\n\n[![Clojars Project](https://img.shields.io/clojars/v/yogthos/config.svg)](https://clojars.org/yogthos/config)\n\n## Usage\n\n### external configuration\n\nIn most cases you'll likely want to specify the configuration file using the `config` environment variable.\nWe will add the dependency to our `project.clj` file and specify the configuration file location using `:jvm-opts`:\n\n```clojure\n(defproject edn-config-test \"0.1.0-SNAPSHOT\"\n  :description \"FIXME: write description\"\n  :url \"http://example.com/FIXME\"\n  :license {:name \"Eclipse Public License\"\n            :url \"http://www.eclipse.org/legal/epl-v10.html\"}\n  :dependencies [[org.clojure/clojure \"1.10.0\"]\n                 [yogthos/config \u003cVERSION\u003e]]\n  ;; configuration will be read from the dev-config.edn file               \n  :jvm-opts [\"-Dconfig=dev-config.edn\"]               \n  :main edn-config-test.core)\n\n```\n\n### embedded configuration\n\nIn some cases you may wish to package configuration in the jar along with the application. In this case the `config.edn` file must be present on the classpath.\n\nLet's take a look at setting up separate configurations for development and production by adding profiles to `project.clj`. We'll create `dev` and `prod` profiles each pointing to a different resource path containing the desired configuration.\n\nFirst, we'll need to create a `config` folder in the root of the project. Under the `config` we will create `dev`\nand `prod` folders. Each of this will contain a file called `config.edn`.\n\nWe'll create a development configuration in `config/dev/config.edn`:\n\n```clojure\n{:db \"jdbc:sqlite:dev.db\"}\n```\n\nand a production configuration in `config/prod/config.edn`:\n\n```clojure\n{:db \"jdbc:sqlite:prod.db\"}\n```\n\nNext, we will add the dependency and the profiles to our `project.clj`:\n\n```clojure\n(defproject edn-config-test \"0.1.0-SNAPSHOT\"\n  :description \"FIXME: write description\"\n  :url \"http://example.com/FIXME\"\n  :license {:name \"Eclipse Public License\"\n            :url \"http://www.eclipse.org/legal/epl-v10.html\"}\n  :dependencies [[org.clojure/clojure \"1.10.0\"]\n                 [yogthos/config \u003cVERSION\u003e]]\n  :profiles {:prod {:resource-paths [\"config/prod\"]}\n             :dev  {:resource-paths [\"config/dev\"]}}\n  :main edn-config-test.core)\n\n```\n\n## Accessing the configuration\n\nWe can now access the config variables the `config.edn` found under the resource path specified in the profile.\nThere are two ways of doing this. We can load a version of config defined as `config.core/env`:\n\n```clojure\n(ns edn-config-test.core\n  (:require [config.core :refer [env]])\n  (:gen-class))\n\n(defn -main []\n  (println (:db env)))\n```\n\nThe config in `env` can be reloaded at runtime by calling the `reload-env` function.\n\nAlternatively, we can call the `config.core/load-env` explicitly to manage the state of the config in the app.\nFor example, if we use the [mount](https://github.com/tolitius/mount) library, we could write the following:\n\n```Clojure\n(ns edn-config-test.core\n  (:require [mount.core :refer [defstate]]\n            [config.core :refer [load-env]])\n  (:gen-class))\n\n(defstate env\n  :start (load-env))\n\n  (defn -main []\n    (mount.core/start)\n    (println (:db env)))    \n```\n\n## Packaging for release\n\nThe application can be packaged using a specific profile by using the Leiningen `with-profile` option. For example, if we wanted to package with the `prod` profile then we'd run the following:\n\n```\nlein with-profile prod uberjar\n```\n\nThe resulting `jar` will contain the config found in `config/prod/config.edn` in case an embedded configuration was used:\n\n```\njava -jar target/edn-config-test.jar\n=\u003e jdbc:sqlite:prod.db\n```\n\n\nAlternatively, we can create a file called `custom-config.edn` that looks as follows:\n\n\n```clojure\n{:db \"jdbc:sqlite:prod-custom.db\"}\n```\n\nThen we can start the app and pass it the `config` environment variable pointing to the location of the file:\n\n```\njava -Dconfig=\"custom-config.edn\" -jar target/edn-config-test.jar\n=\u003e jdbc:sqlite:prod-custom.db\n```\n\n### Attributions\n\nThe `yogthos/config` project is based on the [environ](https://github.com/weavejester/environ) library.\n\n## License\n\nDistributed under the Eclipse Public License, the same as Clojure.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyogthos%2Fconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyogthos%2Fconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyogthos%2Fconfig/lists"}