Skip to content

Commit

Permalink
Nix flake support
Browse files Browse the repository at this point in the history
  • Loading branch information
hissssst committed Mar 30, 2024
1 parent 7b9da4c commit fe47146
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ erl_crash.dump
pathex-*.tar

/.elixir_ls/

# Nix auto shell
.direnv
.envrc
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
description = "Pathex: Elixir language lenses and Access replacement";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
outputs = { nixpkgs, ... }:
let pkgs = nixpkgs.legacyPackages.x86_64-linux;
in {
devShells.x86_64-linux.default = import ./shell.nix { inherit pkgs; };
};
}
30 changes: 30 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{ pkgs ? (import <nixpkgs> { }), ... }:
with pkgs;
let otp = beam.packages.erlangR26;
in pkgs.mkShell {
buildInputs = [
otp.elixir_1_16
otp.erlang
((if otp ? elixir-ls then otp.elixir-ls else otp.elixir_ls).override {
elixir = otp.elixir_1_16;
})
];

shellHook = ''
# keep your shell history in iex
export ERL_AFLAGS="-kernel shell_history enabled"
# Force UTF8 in CLI
export LANG="C.UTF-8"
# this isolates mix to work only in local directory
mkdir -p .nix-mix .nix-hex
export MIX_HOME=$PWD/.nix-mix
export HEX_HOME=$PWD/.nix-hex
# make hex from Nixpkgs available
# `mix local.hex` will install hex into MIX_HOME and should take precedence
export MIX_PATH="${otp.hex}/lib/erlang/lib/hex/ebin"
export PATH=$MIX_HOME/bin:$HEX_HOME/bin:$PATH
'';
}

0 comments on commit fe47146

Please sign in to comment.