# Using nix-shell with flakes over channels

**URL:** https://discourse.nixos.org/t/using-nix-shell-with-flakes-over-channels/36008
**Category:** Help
**Created:** [November 25, 2023, 8:52pm UTC](https://discourse.nixos.org/t/using-nix-shell-with-flakes-over-channels/36008 "2023-11-25T20:52:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![kiara](https://discourse.nixos.org/user_avatar/discourse.nixos.org/kiara/32/37249_2.png) [@kiara](https://discourse.nixos.org/u/kiara)
#### Post date: [November 25, 2023, 8:52pm UTC](https://discourse.nixos.org/t/using-nix-shell-with-flakes-over-channels/36008/1 "2023-11-25T20:52:16Z")

</div>

hi there,  
i’ve been using flakes instead of channels, and was wondering if i could use nix commands (among which `nix-shell`) in such a way as well, but so far haven’t quite figured this out yet:

```sh
$ nix-shell -p nodePackages.npm
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos' does not exist, ignoring
error:
       … <borked>

         at «none»:0: (source not available)

       … while calling the 'import' builtin

         at «string»:1:18:

            1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [(npm)]; } ""
             | ^

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «none»:0: (source not available)

```

now, going the well-trodden path, it works, as expected:

```sh
$ nix-channel --add https://nixos.org/channels/nixpkgs-unstable
$ nix-channel --update
$ echo $NIX_PATH
/home/kiara/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
$ ls /home/kiara/.nix-defexpr/channels/nixpkgs
CONTRIBUTING.md COPYING default.nix doc flake.nix lib maintainers nixos pkgs README.md svn-revision
$ nix-shell -p nodePackages.npm

```

to prevent these from going out of sync, if my `flake.nix` references a `nixpkgs` rev, could i have nix commands use that instead?

---

<div class="post-metadata">

### Author: ![TLATER](https://discourse.nixos.org/user_avatar/discourse.nixos.org/tlater/32/4257_2.png) [@TLATER](https://discourse.nixos.org/u/TLATER)
#### Post date: [November 25, 2023, 9:27pm UTC](https://discourse.nixos.org/t/using-nix-shell-with-flakes-over-channels/36008/2 "2023-11-25T21:27:09Z")

</div>

You can do this: [Do flakes also set the system channel? - #16 by peterhoeg](https://discourse.nixos.org/t/do-flakes-also-set-the-system-channel/19798/16)

There’s some indirection there to avoid problems in edge cases, but the gist is just to add the flake input to `NIX_PATH` under its intended channel name.
