plexus/chestnut — pull request #30 by mklappstuhl (2014-10-16 10:56:37+00:00)
Title: move env var handling into profiles.clj

I've just noticed a problem trying to set some custom environment variables in a `profiles.clj` in the project dir. As soon as you specify an `:env` key in there the `:is-dev` env var is dropped. I.e. the contents of the `:env` key in my `profiles.clj` **replace** the contents of the `:env` key in the `project.clj`.

There are two things that could be done:
1. Put the `:is-dev` key into `profiles.clj`, commit once, add to `.gitignore`
2. Setup two profiles `:project/dev` and `:profiles/dev` that are then aliased to `:dev` (see more below)

**I'm in favour of the first option, as it's much simpler and intuitive to newcomers, PR attached.**

Some IRC conversations I had about this as I was surprised myself:
```
[12:12:15]	martinklepsch: profiles are merged by leiningen
[12:12:38]	martinklepsch: you can check with "lein pprint"
[12:14:38]	the documentation said it'd merge recursively, that's why I was expecting both keys to be in the :env map
[12:15:37]	przl (~przlrkt@80.82.202.196) joined the channel.
[12:15:57]	przl (~przlrkt@80.82.202.196) left IRC. (Client Quit)
[12:17:18]	Lein profiles are merged recursively, though if you have the same profile declared in two locations, only one version is used.
[12:21:53]	weavejester: really? that's unexpected when everything else is merged and ^:replace metadata can be used as well
[12:22:16]	clgv: Yeah, it’s a bit of a gotcha
[12:22:34]	clgv: For example, if you have a :dev profile in your project.clj and a local profiles.clj
[12:22:58]	weavejester: indeed
[12:22:59]	So I tend to have :local/dev and :repo/dev profiles
[12:23:21]	weavejester: and then aliases in the project.clj?
[12:23:21]	Though maybe I should call them :profiles/dev and :project/dev
[12:23:35]	Yeah, :dev [:repo/dev :local/dev]
```

```
[12:36:52]	weavejester: in a project.clj with :env {:is-dev true} it wouldn't make much sense to go the :profiles/dev :project/dev route, right?
[12:37:23]	you could just commit profiles.clj with that single entry and add it to .gitignore afterwards
[12:39:23]	martinklepsch: Well, you really only need to go down the :profiles/dev route if (a) you want to have local overrides to your project that aren’t in source control, and (b) you already have a :dev profile you don’t want to overwrite, but merge into
[12:41:32]	ok, thanks
```