Shells is a VS Code extension that brings the power of Nix flakes directly into your editor! It detects flake.nix files in your workspace and activates them with a single click, making your entire VS Code instance behave as if it's running inside nix develop.
No more switching between terminals or remembering to activate environments manuallyβjust open your project and go! π―
β
Smart Auto-Detection - Automatically finds flake.nix files in your workspace
β
Status Bar Integration - Shows current flake status at a glance
β
Multi-Flake Support - Easily switch between multiple flakes in one workspace
β
Full Workspace Integration - Everything uses your flake environment:
- π₯οΈ All integrated terminals
- π¨ Build tasks and commands
- π Debuggers
- π Language servers
- π¨ Formatters and linters
β
Optional Auto-Activation - Jump straight into your environment on workspace open
β
Zero Configuration - Works out of the box with sensible defaults
Before using Shells, make sure you have:
- πΉ Nix installed on your system
- πΉ Nix flakes enabled in your configuration
π§ How to enable Nix flakes
Add to your ~/.config/nix/nix.conf or /etc/nix/nix.conf:
experimental-features = nix-command flakes
Access these commands via Command Palette (Ctrl+Shift+P / Cmd+Shift+P):
| Command | Description |
|---|---|
| π’ Shells: Enter Nix Flake Environment | Activates the detected or selected flake |
| π΄ Shells: Exit Nix Flake Environment | Deactivates the flake environment |
| π Shells: Select Nix Flake | Choose which flake to use (if multiple exist) |
| π Shells: Show Output | Open the output channel to view detailed logs |
The extension adds a status bar item on the bottom left with visual indicators:
| Icon | Status | Visual Style | Action |
|---|---|---|---|
β
Nix: <flake-name> |
Flake environment ACTIVE | οΏ½ Highlighted with green background | Click to change flakes |
οΏ½π¦ Nix: <flake-name> |
Flake detected but not active | Normal styling | Click to activate |
| π¦ No Flake | No flake.nix found | Normal styling | β |
Tip: When the environment is active, the status bar item has a prominent colored background so you can easily see at a glance whether you're in a flake shell!
The extension includes a comprehensive output channel for debugging:
- π View detailed logs of all nix develop operations
- π See full command output including stdout and stderr
- οΏ½ Track environment variable extraction with counts
- β±οΈ Timestamped operations for troubleshooting
- β Detailed error messages when something goes wrong
Access the output:
- Automatically shows when activating a flake
- Click "Show Output" button in notifications
- Run command:
Shells: Show Output - Or open manually: View β Output β Select "Nix Flake Environment"
Customize the extension via VS Code settings:
| Setting | Type | Default | Description |
|---|---|---|---|
shells.autoActivate |
boolean | false |
Automatically activate flake environment on workspace open |
shells.flakePath |
string | "" |
Path to flake.nix (relative to workspace root). Empty = auto-detect |
graph LR
A[π Open Workspace] --> B{π flake.nix found?}
B -->|Yes| C[π Show in Status Bar]
B -->|No| D[π€ Idle]
C --> E[π Click to Activate]
E --> F[β‘ Run nix develop]
F --> G[π Extract Environment]
G --> H[βοΈ Configure VS Code]
H --> I[π Ready to Code!]
Step-by-step:
- π Extension searches for
flake.nixfiles when you open a workspace - π Displays flake status in the status bar
- π Click the status bar or run "Enter Nix Flake Environment" command
- β‘ The extension runs
nix developand:- π Extracts all environment variables
- π₯οΈ Configures integrated terminal environment
- βοΈ Updates workspace settings for tools and language servers
- π All new terminals, tasks, debuggers, and LSPs use your flake environment!
Result: Your entire VS Code behaves as if it's running inside nix develop!
Here's a simple flake.nix that the extension can detect:
{
description = "π My awesome development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.${system}.default = pkgs.mkShell {
buildInputs = with pkgs; [
nodejs_20
python3
git
# Add more packages here!
];
shellHook = ''
echo "π Welcome to your dev environment!"
'';
};
};
}With this flake, the extension automatically gives you access to:
- β Node.js 20
- β Python 3
- β Git
- β Any other packages you add!
Want to contribute or customize the extension? Here's how to get started:
- π¦ Nix with flakes enabled
- π¦ VS Code
# 1οΈβ£ Clone the repository
git clone https://github.com/FreaxMATE/shells.git
cd shells
# 2οΈβ£ Enter the development environment (using its own flake! π)
nix develop
# 3οΈβ£ Install dependencies
npm install
# 4οΈβ£ Compile TypeScript
npm run compile
# 5οΈβ£ Watch mode (auto-recompile on changes)
npm run watchPress F5 in VS Code to launch the Extension Development Host and test your changes! π
# 1οΈβ£ Enter dev environment
nix develop
# 2οΈβ£ Package the extension
npx @vscode/vsce package
# 3οΈβ£ Install the .vsix file
code --install-extension shells-0.0.1.vsixπ‘ NixOS Tip: Use
npxinstead of global npm installs for better compatibility!
- Open VS Code
- Navigate to Extensions view (
Ctrl+Shift+X/Cmd+Shift+X) - Click the
...menu at the top - Select "Install from VSIX..."
- Choose the
shells-0.0.1.vsixfile
- Open a workspace with a
flake.nixfile - Look for the status bar item: π¦ Nix:
<flake-name> - Open Command Palette (
Ctrl+Shift+P) and search for "Shells" commands
Contributions are welcome and appreciated! π
- π Found a bug? Open an issue
- π‘ Have an idea? Start a discussion
- π§ Want to contribute code? Submit a pull request
The extension fully supports Python development and Jupyter notebooks! When you activate a flake environment, the extension:
- π Detects the Python interpreter from your flake's PATH
- βοΈ Configures VS Code's Python extension to use the flake's Python
- π Enables Jupyter notebooks with all packages from your flake
{
description = "Python Data Science Environment";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
};
outputs = { self, nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
in {
devShells."${system}".default = pkgs.mkShell {
packages = with pkgs; [
python312Packages.python
python312Packages.numpy
python312Packages.matplotlib
python312Packages.pandas
python312Packages.scipy
python312Packages.notebook
python312Packages.jupyter
python312Packages.pip
];
};
};
}After activating a flake environment for the first time, you must reload VS Code for the Python and Jupyter extensions to pick up the new interpreter. The extension will prompt you to do this automatically.
Click "Reload Window" when prompted, or manually run: Developer: Reload Window from the Command Palette.
VS Code's Python and Jupyter extensions cache the interpreter path and environment. A reload ensures they discover and use the Python from your Nix flake environment.
This project is licensed under the GPL-3.0-or-later License.
See LICENSE for details.
Made with β€οΈ and Nix
β Star this repo if you find it useful!