cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
4.04k stars 303 forks source link

Merge `devenvs` #439

Open shadowrylander opened 1 year ago

shadowrylander commented 1 year ago

Hello!

So mergeEnvs can be used to merge multiple nix-shells; is any way to do something similar for devenvs? I tried overwriting the shellHook for a devenv, for example, but it didn't work. I'd like to use this feature to create a bunch of useful default devenvs, then allow users to append to them as necessary.

Thank you kindly for the help!

domenkozar commented 1 year ago

That's done with imports: https://devenv.sh/composing-using-imports/

shadowrylander commented 1 year ago

Is there no other way? I was hoping I could merge them directly from arguments passed to the function with the default devenvs.

domenkozar commented 1 year ago

Can you show an example how this would work?

shadowrylander commented 1 year ago

So I have a function which recursively merges flake outputs; I was thinking that, if the object is a devenv, if there are a default set of packages for a particular devenv, then a user could add a specific enterShell for that devenv as well:

mkOutputs = outputs: recursiveUpdateAll [
    # A default `devenv'
    { devShells.x86_64-linux.python-devenv.packages = [ pkgs.x86_64-linux.python3 ]; }

    outputs
];

# A user's additions;
mkOutputs { devShells.x86_64-linux.python-devenv.enterShell = "echo $PYTHONPATH; exit"; };
domenkozar commented 1 year ago

If you're using flakes, you can just pass them as modules.

On Tue, Feb 28, 2023, 11:37 Jeet Ray @.***> wrote:

So I have a function which recursively merges flake outputs; I was thinking that, if the object is a devenv, if there are a default set of packages for a particular devenv, then a user could add a specific enterShell for that devenv as well:

mkOutputs = outputs: recursiveUpdateAll [

A default `devenv'

{ devShells.x86_64-linux.python-devenv.packages = [ pkgs.x86_64-linux.python3 ]; }

outputs

];

A user's additions;mkOutputs { devShells.x86_64-linux.python-devenv.enterShell = "echo $PYTHONPATH; exit"; };

— Reply to this email directly, view it on GitHub https://github.com/cachix/devenv/issues/439#issuecomment-1447563756, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA63AZKMI66QS3PM3MT243WZV6IFANCNFSM6AAAAAAVJ2JTVQ . You are receiving this because you commented.Message ID: @.***>

shadowrylander commented 1 year ago

So I'd still have to account for extra modules manually, correct?

domenkozar commented 1 year ago

I'm not sure what manually refers to. Ideally we could work on a full example flake.nix and a short user session of what's expected to happen.

sylvorg commented 1 year ago

So by manually, I mean taking any devenv settings that would have been merged from the argument set passed to the function, and adding them manually to the devenv.lib.mkShell function's module argument, instead of merging them along with everything else, such as regular mkShell shellHooks or propagatedBuildInputs, etc.

sylvorg commented 1 year ago

Also, sorry; second account. I can never keep track of these things... 😅