Reduce boilerplate with `devShell` flakes

Hi everybody,

I’ve started using flake-based development shells (with nix-direnv) using this pattern in flake.nix:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { nixpkgs, flake-utils, ... }:
    flake-utils.lib.eachDefaultSystem (system:
      let pkgs = import nixpkgs { inherit system; };
      in with pkgs; {
        devShell = mkShell { buildInputs = [ hugo go ]; };
      });
}

(and then use flake in .envrc).

This setup works really well for me, but I’m a bit annoyed about the amount of boilerplate that I have to add to every repository, if all I want is a few packages auto-installed.

Is there a way to write the same thing more concisely?

Mike

Not much more concisely. You could replace

let pkgs = import nixpkgs { inherit system; };
      in with pkgs; {

with

with import nixpkgs { inherit system; }; {

But other than that, it’s all kinda necessary.

Ah yes. That does save a line:-)

It’s uhm, why I made https://devenv.sh :slight_smile: See Packages - devenv

Oh. That does look nice! I’m going to try this out…