Flake: vscode-with-extensions

I got burned several times as extension updates in vscode broke my jupyter notebook. I therefore decided to make vscode part of the development environment such that I get not surprised any more by updates.

flake.nix

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

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs {
          inherit system;
          config.allowUnfree = true;
        };

        demos = pkgs.callPackage ./. { };
      in
      {
        packages = { inherit demos; };
        devShell = demos.shell;
      });
}

default.nix

{ lib, pkgs }:

let
  python = pkgs.python310;

  myvscode = pkgs.vscode-with-extensions.override {
    vscodeExtensions = with pkgs.vscode-extensions; [
      ms-python.python
      ms-toolsai.jupyter
      ms-toolsai.jupyter-keymap
      ms-toolsai.jupyter-renderers
      ms-toolsai.vscode-jupyter-cell-tags
      ms-toolsai.vscode-jupyter-slideshow
    ];
  };

  pythonRunPackages = with python.pkgs;[
    python
    ipywidgets
    jupyter
    ipykernel
    plotly
  ];

  pythonDevPackages = with python.pkgs;[
    black
    flake8
    pylint
    setuptools
  ] ++ pythonRunPackages;

  venv = python.withPackages (ps: pythonDevPackages);
in
{
  inherit python pythonRunPackages pythonDevPackages venv;

  shell = pkgs.mkShell {
    buildInputs = pythonDevPackages ++ [ myvscode ];
  };
}

However, the extensions are not enabled, and I cannot run any *.py file or run jupyter notebooks:
nix develop -c code .

I guess, the grayed extensions are from my global vscode installation. Some jupyter extensions seem to be loaded, but not all and not the python extension.

Do you have any ideas what might be wrong?

2 Likes

Same problem here, except

  • Extensions installed via the flake are not greyed out
  • According to code --list-extensions reports the extensions are installed, but they neither show up in the Extensions UI, nor do they work or can I find their settings.
    jnoortheen.nix-ide is a great test candidate