From fe471463ed22f76d9ecedeed7cb3619dc1af2bc4 Mon Sep 17 00:00:00 2001 From: hissssst Date: Sat, 30 Mar 2024 18:01:41 +0400 Subject: [PATCH] Nix flake support --- .gitignore | 4 ++++ flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 9 +++++++++ shell.nix | 30 ++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 shell.nix diff --git a/.gitignore b/.gitignore index 68d8f8d..f388d4b 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,7 @@ erl_crash.dump pathex-*.tar /.elixir_ls/ + +# Nix auto shell +.direnv +.envrc diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..93b865c --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1711715736, + "narHash": "sha256-9slQ609YqT9bT/MNX9+5k5jltL9zgpn36DpFB7TkttM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "807c549feabce7eddbf259dbdcec9e0600a0660d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..92bb747 --- /dev/null +++ b/flake.nix @@ -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; }; + }; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..1b958fb --- /dev/null +++ b/shell.nix @@ -0,0 +1,30 @@ +{ pkgs ? (import { }), ... }: +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 + ''; +}