Shopify / shadowenv

reversible directory-local environment variable manipulations
https://shopify.github.io/shadowenv/
MIT License
394 stars 18 forks source link

Proposal: `shadowenv assimilate` #52

Open burke opened 5 years ago

burke commented 5 years ago

Shadowenv could have a feature to convert other environment manipulation tools' configs to a format it can understand. For example:

# .env
A=b
$ shadowenv assimilate
assimilated .env as .shadowenv.d/050-dotenv.lisp
; 050-dotenv.lisp
(env/set "A" "b")

This is obviously the most trivial case, but we could do similar things for:

Because of Shadowenv's lack of ability to do much of anything dynamic at load-time, this would essentially function as a "compiler" for these environment files.

One trick to try to make these files at least marginally portable would be to replace the user's home directory in any outputs with (concat (env/get "HOME") ...).

If we wanted to keep tabs on a mapping between the original and the assimilated version, we could encode a checksum/hash of the source file in the assimilated file as a comment on the first line. With this, shadowenv or dev could potentially observe these files when entering a directory and inform the user about out-of-date-ness.

lavoiesl commented 5 years ago

I would start with a simple compiler, we can tackle the monitoring later. SGTM šŸ‘

burke commented 5 years ago

Another idea I just had, and maybe the way to start this feature out, is:

shadowenv assimilate --type=dotenv < .env > .shadowenv.d/050-dotenv.lisp
shadowenv assimilate --type=nix-setup-hook < $some_nix_path/nix-support/setup-hook > .shadowenv.d/050-nix-something.lisp

It'd be pretty cool to extract some of this Shadowlisp generation stuff out of dev and directly into Shadowenv.

paarthmadan commented 4 years ago

Is this being worked on and/or urgent? If not, I'd like to give it a stab. I'm still in school, so I think this could be a good motivation when learning about compilers.

lavoiesl commented 4 years ago

Go ahead šŸ‘