Last active
June 3, 2020 16:22
-
-
Save mveytsman/6f15ba6a17d9e37f7a7cd5eb06c748a9 to your computer and use it in GitHub Desktop.
elixir project shell.nix (ongoing project)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with (import <nixpkgs> { }); | |
let | |
inherit (lib) optional; | |
inherit (python3.pkgs) buildPythonPackage fetchPypi; | |
basePackages = | |
[ git libxml2 openssl zlib curl libiconv docker-compose postgresql ] | |
++ optional stdenv.isLinux inotify-tools; | |
elixirPackages = [ elixir_1_10 ]; | |
nodePackages = [ nodejs yarn ]; | |
click = buildPythonPackage rec { | |
pname = "click"; | |
version = "6.7"; | |
src = fetchPypi { | |
inherit pname version; | |
sha256 = "02qkfpykbq35id8glfgwc38yc430427yd05z1wc5cnld8zgicmgi"; | |
}; | |
doCheck = false; | |
}; | |
gigalixir = let | |
localPython = python3.override { | |
packageOverrides = self: super: { | |
# Packages that aren't in nixpkgs so we need to build them | |
rollbar = super.buildPythonPackage rec { | |
pname = "rollbar"; | |
version = "0.13.18"; | |
src = fetchPypi { | |
inherit pname version; | |
sha256 = "1vb18jj7fi65la1zrfbgjd20g81fqmsfp4dhdqq552rsl5zfld7q"; | |
}; | |
buildInputs = with super; [ requests ]; | |
doCheck = false; | |
}; | |
# These packages are locked to versions that aren't the latest in nixpkgs, so we need to fetch the downgraded versions | |
click = super.click.overridePythonAttrs (oldAttrs: rec { | |
version = "6.7"; | |
src = oldAttrs.src.override { | |
inherit version; | |
sha256 = "02qkfpykbq35id8glfgwc38yc430427yd05z1wc5cnld8zgicmgi"; | |
}; | |
}); | |
pygments = super.pygments.overridePythonAttrs (oldAttrs: rec { | |
version = "2.2.0"; | |
src = oldAttrs.src.override { | |
inherit version; | |
sha256 = "1k78qdvir1yb1c634nkv6rbga8wv4289xarghmsbbvzhvr311bnv"; | |
}; | |
}); | |
requests = super.requests.overridePythonAttrs (oldAttrs: rec { | |
version = "2.20.0"; | |
src = oldAttrs.src.override { | |
inherit version; | |
sha256 = "033p8ax4qs81g0c95ngincm52q84g1xnlazk4vjzdjhpxfmgvp4r"; | |
}; | |
}); | |
stripe = super.stripe.overridePythonAttrs (oldAttrs: rec { | |
version = "1.51.0"; | |
src = oldAttrs.src.override { | |
inherit version; | |
sha256 = "088xv7xg1a1mdsplsxl4zjdh0agmf3zf7r4y07yl8v2c7887w2f9"; | |
}; | |
}); | |
urllib3 = super.urllib3.overridePythonAttrs (oldAttrs: rec { | |
version = "1.24.3"; | |
src = oldAttrs.src.override { | |
inherit version; | |
sha256 = "1x0slqrv6kixkbcdnxbglvjliwhc1payavxjvk8fvbqjrnasd4r3"; | |
}; | |
}); | |
idna = super.idna.overridePythonAttrs (oldAttrs: rec { | |
version = "2.7"; | |
src = oldAttrs.src.override { | |
inherit version; | |
sha256 = "05jam7d31767dr12x0rbvvs8lxnpb1mhdb2zdlfxgh83z6k3hjk8"; | |
}; | |
}); | |
}; | |
}; | |
in with localPython.pkgs; | |
buildPythonApplication rec { | |
pname = "gigalixir"; | |
version = "1.1.9"; | |
src = fetchPypi { | |
inherit pname version; | |
sha256 = "1gxx411qkyd330v7sam8nlikhxj0dn2a9ca1gwkckscibbpa47ra"; | |
}; | |
propagatedBuildInputs = [ setuptools click pygments requests stripe rollbar ]; | |
postPatch = '' | |
# pytest-runner is deprecated, and we won't use it | |
substituteInPlace setup.py --replace "'pytest-runner'," "" | |
''; | |
doCheck = false; | |
}; | |
inputs = basePackages ++ elixirPackages ++ nodePackages ++ [ gigalixir ]; | |
localPath = ./. + "/local.nix"; | |
final = if builtins.pathExists localPath then | |
inputs ++ (import localPath) | |
else | |
inputs; | |
# define shell startup command with special handling for OSX | |
baseHooks = '' | |
export PS1='\n\[\033[1;32m\][nix-shell:\w]($(git rev-parse --abbrev-ref HEAD))\$\[\033[0m\] ' | |
export LANG=en_US.UTF-8 | |
set -a | |
source .env | |
set +a | |
''; | |
elixirHooks = '' | |
mkdir -p .nix-mix | |
mkdir -p .nix-hex | |
export MIX_HOME=$PWD/.nix-mix | |
export HEX_HOME=$PWD/.nix-hex | |
export PATH=$MIX_HOME/bin:$PATH | |
export PATH=$HEX_HOME/bin:$PATH | |
export ERL_AFLAGS="-kernel shell_history enabled" | |
''; | |
nodeHooks = '' | |
export NODE_BIN=$PWD/assets/node_modules/.bin | |
export PATH=$NODE_BIN:$PATH | |
''; | |
hooks = baseHooks + elixirHooks + nodeHooks; | |
in stdenv.mkDerivation { | |
name = "mc-hammer"; | |
buildInputs = final; | |
shellHook = hooks; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment