How to get VSCode to load my workspace's nix env

I’m brand new to nix (started last weekend) I am trying to get my Ruby dev env working. I want to use VS Code with various ruby plugins, and I just migrated from rvm.

I am using direnv ‘use nix’, with in my Ruby on Rails project’s root the following default.nix file:

  pkgs = import <nixpkgs> {};
  oldPackagesSource = fetchTarball {
    url = "";

  oldPackages = import oldPackagesSource {};
pkgs.mkShell rec
  buildInputs = [
    oldPackages.ruby_2_7 # Installs Ruby 2.7.0

    export PATH=~/.gem/ruby/2.7.0/bin:$PATH

It works flawlessly on the terminal, I have access to ruby, node, my gems, as soon as I enter the directory.

Now, I’m trying to get Visual Studio Code to inherit this environment whenever I open this project, and I can’t, for the love of me, get it to work. I am trying to follow this guide over here but whatever I try, my other VS Code extensions can’t find my binaries, or they’re trying to use my system ruby. It’s clear that the PATH is not properly set.

If I start VS Code right away from the terminal using code . from my direnv-enabled directory, it (obviously) inherits the $PATH from my session and everything works like a charm. it somehow also doesn’t work.

I’ve also tried GitHub - arrterian/nix-env-selector: Allows switch environment for Visual Studio Code using Nix Package Manager. which shows the environment, tells me it loaded it, but I get the exact same result.

What am I missing here?