#!/bin/bash

if [ -e $HOME/bws_skip_nixpkgs ]; then                                                                                  
  $HOME/services/_sandbox $*                                                                                            
  exit $?                                                                                                               
fi 

# Add support for nix-shell if available
if [[ -e "shell.nix" && $(which nix-shell) ]]; then
  echo Loading Nix packages
  nix-shell --run "$HOME/services/_sandbox $*"
elif [[ -e "packages.nix" && $(which nix-shell) ]]; then
  echo Loading Nix packages
  nix-shell -p $(xargs -a packages.nix echo) --run "$HOME/services/_sandbox $*"
else
  $HOME/services/_sandbox $*
fi

retVal=$?
exit $retVal
