How can I include nix packages into a nixos vm for the purpose of adding them to /nix/store without polluting the global system packages?
10:37 12 Nov 2025

I'm building a nixos vm using nixos-shell and I'm using the following to add the dependencies of a example project to the vm:

  let 
  appRepo = pkgs.callPackage (builtins.fetchGit {
      url = "/home/chris/NewProjects/Example";
      rev = "95f6b51548163dd999c945e5f417bd551d9ed49f";
    }) {};
  in 
  environment.systemPackages =
  [  pkgs.docker
     pkgs.vim
     pkgs.git
     pkgs.htop
     pkgs.ripgrep
  ] ++ [
   (pkgs.callPackage hdev {}) 
  ] ++ appRepo.env.buildInputs; ## this line here

This avoids the need to download dependencies of the example project. However it has the side effect of polluting the global $PATH / system packages.

Is there a cleaner way to add these dependencies in without this side effect?

nix