Nix-dev-shells: per-project devshells for programming


I would like to introduce nix-dev-shells a flake helps setup per project programming environments using dev-shell.

So far I only ported my ruby shell configuration and plan on adding Go and Python shells.

Contributions and feedback are both welcome!


Is this like opinionated devshells for programming?

Like if someone just want a working Typescript devshell and doesn’t care about the details and would get pkgs like : eslint, prettier, typescript, typescript-language-server. Would it be a good idea to have optional stuff? Like if the person doesn’t want prettier or wants yarn.

I’m guessing in many cases it might not matter to install a couple of extra deps. I mean on Ubuntu I don’t mind installing the build-essentials or whatever it’s called.

Another question, is postgresql_11 really needed for ruby?

They are definitely opinionated, but should cover the basic use cases. As for language server and linters, it really depends on how you set them up, what kind of editor you use etc.

As for postgresql_11 it is indeed not needed, this is a dependency I usually pull when working with ruby on rails.

An nice approach to the problem might be to implement a module system, so you could do: ruby.rails.enable = true and pull-in rails related dependencies.

1 Like

@bbigras I’ve experimented with modules to address your concerns about the extra dependencies. I feel like it hits the right spot and could enable some interesting use-cases.

The ruby example would look like this:

  devShell = pkgs.mkDevShell {
    imports = dev-shells.devshellModules."${system}";

    # Enable linter support, this will trigger the installation of the `ruby.linter`.
    linter.enable = true;
    # Enable language server support, this will trigger the installation of the `ruby.languageServer`.
    languageServer.enable = true;

    # Enable ruby support
    ruby.enable = true;

    # Add dependencies specific to Ruby on Rails applications.
    ruby.rails.enable = true;

You can review the changes on module-system branch: