Skip to content

Instantly share code, notes, and snippets.

@tvon tvon/function.sh
Created Mar 7, 2016

Embed
What would you like to do?
activate() {
if [ $# -eq 0 ];
then
if [ -f .nix ];
then
nix-shell .nix -A localEnv
else
echo '.nix file not found' 1>&2
fi
else
nix-shell ~/dev/environments/$1.nix -A localEnv
fi
}
let
pkgs = import <nixpkgs> {};
stdenv = pkgs.stdenv;
ruby = pkgs.ruby_2_3_0;
postgresql = pkgs.postgresql;
in rec {
localEnv = stdenv.mkDerivation rec {
name = "ruby-2.3.0";
version = "1.0";
GEM_HOME = "${builtins.getEnv "HOME"}/.gems-ruby-2.3.0";
GEM_PATH = "${GEM_HOME}:${builtins.getEnv "GEM_PATH"}";
PATH = "${builtins.getEnv "PATH"}:${GEM_HOME}/bin";
shellHook = ''
export PS1="\n\[\033[1;32m\][$(ruby --version):\w]$\[\033[0m\] "
'';
src = ./.;
buildInputs = with pkgs; [
ruby
postgresql
# For nokogiri, needs to be installed via
# gem install nokogiri -- --use-system-libraries
# pkg-config seems to work for setting the paths.
git libxml2 libxslt libffi pkgconfig
];
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.