cachix / devenv

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

Can't use more than one shell with flakes #1172

Open wokalski opened 3 weeks ago

wokalski commented 3 weeks ago

Describe the bug I use nix flakes and I cannot use more than one shell because devenv now "temporarily" requires adding devenv-up = self.devShells.${system}.default.config.procfileScript; attribute to packages. I know I can replace default with any other shell but it breaks any composability.

To reproduce Spin up a devenv using the fake setup from the example and try to add another devshell.

Version 1.0.4 with flakes

sandydoo commented 2 weeks ago

The UX around this is not great, but here's how to create multiple shells with plain flakes:

# Assuming flake-utils here to skip setting system
{
  packages = {
    # The "default" shell
    devenv-up = self.devShells.${system}.default.config.procfileScript;
    # Another shell. The pattern is: <shellName>-devenv-up
    cross-devenv-up = self.devShells.${system}.cross.config.procfileScript;
  };

  devShells = {
    default = devenv.lib.mkShell { ... };
    cross = devenv.lib.mkShell { ... };
  };
}

If you're using flake-parts, the devenv-up packages are created for you.

sandydoo commented 2 weeks ago

What does seem broken in both plain flakes and flake-parts is launching processes with devenv up inside the shell.

For plain flakes, config._module.args.name is not a thing AFAIKT, so we always fall back to launching the "default" package.

For flake-parts, the devenv flake-integration script is not sourced in the shell.