add nix flake with devshell

This commit is contained in:
Paweł Dąbrowski 2024-07-29 16:52:20 +02:00
parent dfaa2a963d
commit e1c038072f
4 changed files with 65 additions and 1 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake

3
.gitignore vendored
View File

@ -26,3 +26,6 @@ xler-*.tar
/.elixir_ls /.elixir_ls
*.xls *.xls
.direnv
.state

26
flake.lock generated Normal file
View File

@ -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
}

34
flake.nix Normal file
View File

@ -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}"
'';
};
};
}