-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
446 additions
and
154 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#################################### | ||
# Environment setup for Nix shells # | ||
#################################### | ||
|
||
# From https://github.com/direnv/direnv/wiki/Nix#persistent-cached-shell | ||
# | ||
# Usage: use_nix [...] | ||
# | ||
# Load environment variables from `nix-shell`. | ||
# If you have a `default.nix` or `shell.nix` one of these will be used and | ||
# the derived environment will be stored at ./.direnv/env-<hash> | ||
# and symlink to it will be created at ./.direnv/default. | ||
# Dependencies are added to the GC roots, such that the environment remains persistent. | ||
# | ||
# Packages can also be specified directly via e.g `use nix -p ocaml`, | ||
# however those will not be added to the GC roots. | ||
# | ||
# The resulting environment is cached for better performance. | ||
# | ||
# To trigger switch to a different environment: | ||
# `rm -f .direnv/default` | ||
# | ||
# To derive a new environment: | ||
# `rm -rf .direnv/env-$(md5sum {shell,default}.nix 2> /dev/null | cut -c -32)` | ||
# | ||
# To remove cache: | ||
# `rm -f .direnv/dump-*` | ||
# | ||
# To remove all environments: | ||
# `rm -rf .direnv/env-*` | ||
# | ||
# To remove only old environments: | ||
# `find .direnv -name 'env-*' -and -not -name `readlink .direnv/default` -exec rm -rf {} +` | ||
# | ||
use_nix() { | ||
set -e | ||
|
||
local shell="shell.nix" | ||
if [[ ! -f "${shell}" ]]; then | ||
shell="default.nix" | ||
fi | ||
|
||
if [[ ! -f "${shell}" ]]; then | ||
fail "use nix: shell.nix or default.nix not found in the folder" | ||
fi | ||
|
||
local dir="${PWD}"/.direnv | ||
local default="${dir}/default" | ||
if [[ ! -L "${default}" ]] || [[ ! -d `readlink "${default}"` ]]; then | ||
local wd="${dir}/env-`md5sum "${shell}" | cut -c -32`" # TODO: Hash also the nixpkgs version? | ||
mkdir -p "${wd}" | ||
|
||
local drv="${wd}/env.drv" | ||
if [[ ! -f "${drv}" ]]; then | ||
log_status "use nix: deriving new environment" | ||
IN_NIX_SHELL=1 nix-instantiate --add-root "${drv}" --indirect "${shell}" > /dev/null | ||
nix-store -r `nix-store --query --references "${drv}"` --add-root "${wd}/dep" --indirect > /dev/null | ||
fi | ||
|
||
rm -f "${default}" | ||
ln -s `basename "${wd}"` "${default}" | ||
fi | ||
|
||
local drv=`readlink -f "${default}/env.drv"` | ||
local dump="${dir}/dump-`md5sum ".envrc" | cut -c -32`-`md5sum ${drv} | cut -c -32`" | ||
|
||
if [[ ! -f "${dump}" ]] || [[ "${XDG_CONFIG_DIR}/direnv/direnvrc" -nt "${dump}" ]]; then | ||
log_status "use nix: updating cache" | ||
|
||
old=`find "${dir}" -name 'dump-*'` | ||
nix-shell "${drv}" --show-trace "$@" --run 'direnv dump' > "${dump}" | ||
rm -f ${old} | ||
fi | ||
|
||
direnv_load cat "${dump}" | ||
|
||
watch_file "${default}" | ||
watch_file shell.nix | ||
if [[ ${shell} == "default.nix" ]]; then | ||
watch_file default.nix | ||
fi | ||
} | ||
|
||
use nix |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
[ | ||
inputs: ["{mix,.formatter,.credo}.exs", "{config,lib,test}/**/*.{ex,exs}"], | ||
inputs: [ | ||
"{mix,.iex,.formatter,.credo}.exs", | ||
"{config,lib,rel,test}/**/*.{ex,exs}" | ||
], | ||
line_length: 80 | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,40 @@ | ||
# The directory Mix will write compiled artifacts to. | ||
/_build/ | ||
## | ||
## Application artifacts | ||
## | ||
|
||
# If you run "mix test --cover", coverage assets end up here. | ||
/cover/ | ||
# direnv cache for Nix shells | ||
/.direnv/ | ||
|
||
# The directory Mix downloads your dependencies sources to. | ||
/deps/ | ||
|
||
# Where 3rd-party dependencies like ExDoc output generated docs. | ||
/doc/ | ||
# Elixir build directory | ||
/_build/ | ||
|
||
# Ignore .fetch files in case you like to edit your project deps locally. | ||
# Elixir dependencies | ||
/deps/ | ||
/.fetch | ||
|
||
# If the VM crashes, it generates a dump, let's ignore it too. | ||
erl_crash.dump | ||
|
||
# Also ignore archive artifacts (built via "mix archive.build"). | ||
# Elixir binary files | ||
*.beam | ||
*.ez | ||
/xgen-*.tar | ||
/xgen | ||
|
||
# Elixir LS artifacts. | ||
/.elixir_ls/ | ||
# Test coverage and documentation | ||
/cover/ | ||
/doc/ | ||
|
||
# Mnesia database | ||
/Mnesia.* | ||
|
||
## | ||
## Editor artifacts | ||
## | ||
|
||
/.elixir_ls/ | ||
/.history/ | ||
|
||
## | ||
## Crash dumps | ||
## | ||
|
||
# Erang VM | ||
erl_crash.dump |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
language: elixir | ||
elixir: | ||
- 1.6 | ||
- 1.7 | ||
- 1.8 | ||
- 1.9 | ||
otp_release: | ||
- 20.3 | ||
- 21.2 | ||
- 22.0 | ||
matrix: | ||
exclude: | ||
- elixir: 1.6 | ||
otp_release: 22.0 | ||
- elixir: 1.7 | ||
otp_release: 20.3 | ||
- elixir: 1.8 | ||
otp_release: 20.3 | ||
- elixir: 1.9 | ||
otp_release: 20.3 | ||
env: | ||
- PLT_DIR=$HOME/.plt | ||
before_script: | ||
- mkdir -p $PLT_DIR | ||
- mix deps.compile | ||
- MIX_ENV=test mix deps.compile | ||
- travis_wait mix dialyzer --plt | ||
script: | ||
- mix compile --force --verbose --warnings-as-errors | ||
- mix test --trace | ||
- mix dialyzer --no-compile --no-check --halt-exit-status | ||
- mix credo | ||
- if [[ "$TRAVIS_ELIXIR_VERSION" == "1.9.1" ]]; then mix format --check-formatted; fi | ||
cache: | ||
directories: | ||
- $PLT_DIR |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# Changelog | ||
|
||
## v0.1.3 | ||
|
||
* Fix the time units | ||
|
||
## v0.1.2 | ||
|
||
* Add an index on timestamp | ||
|
Oops, something went wrong.