diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index d7674e0..bf522a2 100644 --- a/.gitignore +++ b/.gitignore @@ -25,4 +25,7 @@ xler-*.tar /priv /.elixir_ls -*.xls \ No newline at end of file +*.xls + +.direnv +.state \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3914d2c --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1722062969, + "narHash": "sha256-QOS0ykELUmPbrrUGmegAUlpmUFznDQeR4q7rFhl8eQg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b73c2221a46c13557b1b3be9c2070cc42cf01eb3", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..a307b86 --- /dev/null +++ b/flake.nix @@ -0,0 +1,34 @@ +{ + inputs = { nixpkgs.url = "nixpkgs/nixos-unstable"; }; + + outputs = { self, nixpkgs }: { + devShell.x86_64-linux = let + system = "x86_64-linux"; + pkgs = import nixpkgs { inherit system; }; + beam = pkgs.beam.packages.erlang_27; + elixir = beam.elixir_1_17; + elixir-ls = (beam.elixir-ls.override { inherit elixir; }); + in pkgs.mkShell { + buildInputs = [ + elixir + elixir-ls + pkgs.rustc + pkgs.cargo + pkgs.rust-analyzer + pkgs.rustfmt + ]; + shellHook = '' + # this allows mix to work on the local directory + mkdir -p .state/mix .state/hex + export MIX_HOME=$PWD/.state/mix + export HEX_HOME=$PWD/.state/hex + export PATH=$MIX_HOME/bin:$MIX_HOME/escripts:$HEX_HOME/bin:$PATH + # TODO: not sure how to make hex available without installing it afterwards. + mix local.hex --if-missing --force + export LANG=en_US.UTF-8 + export ERL_AFLAGS="-kernel shell_history enabled -kernel shell_history_path '\"$PWD/.state\"' -kernel shell_history_file_bytes 1024000" + export RUST_SRC_PATH="${pkgs.rustPlatform.rustLibSrc}" + ''; + }; + }; +}