Skip to content

Instantly share code, notes, and snippets.

@tvon
Created March 7, 2016 04:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tvon/a89be0dfc32bef5c6fd5 to your computer and use it in GitHub Desktop.
Save tvon/a89be0dfc32bef5c6fd5 to your computer and use it in GitHub Desktop.
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