Skip to content

Instantly share code, notes, and snippets.

@mtrsk
Forked from aabs/shell.nix
Created July 19, 2019 12:45
Show Gist options
  • Save mtrsk/48845e72fad9cfc87ea0d5d621022b67 to your computer and use it in GitHub Desktop.
Save mtrsk/48845e72fad9cfc87ea0d5d621022b67 to your computer and use it in GitHub Desktop.
A simple nix-shell script to establish an environment for Phoenix, Elixir and PostgreSQL development
{ nixpkgs ? import <nixpkgs> {}
, version ? "0.1"
, proxy ? "http://10.183.23.58:3128"
}:
with nixpkgs;
let
elixir = beam.packages.erlangR21.elixir_1_7;
nodejs = nodejs-10_x;
postgresql = postgresql100;
deps =
[ elixir
nodejs
git
postgresql
glibcLocales
fish
neovim
vimPlugins.spacevim
inotify-tools
];
env = buildEnv {
name = "ex-build-environment";
paths = deps;
};
in
stdenv.mkDerivation rec {
name = "ex-${version}";
buildInputs = [ env ];
phases = ["nobuild"];
postPatch = "patchShebangs .";
preConfigure = ''
echo Running preConfigure...
echo ${version} > VERSION
((git log -1 --pretty=format:"%H") || echo dirty) > GIT_COMMIT_ID
./boot
'';
HTTP_PROXY = "${proxy}";
HTTPS_PROXY = "${proxy}";
http_proxy = "${proxy}";
https_proxy = "${proxy}";
shellHook = ''
# "nix-shell --pure" resets LANG to POSIX, this breaks "make TAGS".
export LANG="en_US.UTF-8"
export PGDATA="$PWD/db"
mix local.hex
mix archive.install hex phx_new 1.4.0
'';
enableParallelBuilding = true;
stripDebugFlags = [ "-S" ];
# Without this, we see a whole bunch of warnings about LANG, LC_ALL and locales in general.
# In particular, this makes many tests fail because those warnings show up in test outputs too...
# The solution is from: https://github.com/NixOS/nix/issues/318#issuecomment-52986702
LOCALE_ARCHIVE = if stdenv.isLinux then "${glibcLocales}/lib/locale/locale-archive" else "";
nobuild = ''
echo Do not run this derivation with nix-build, it can only be used with nix-shell
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment