What is the canonical way of installing Elixir or Erlang > 19 with `nix` on a non-NixOS system?

前端 未结 3 438
被撕碎了的回忆
被撕碎了的回忆 2021-01-01 02:40

Please explain it as you would to a 10-year-old, from the point after the Nix package manager is installed on a non-NixOS machine. For example, I am on a Mac, and there isn\

3条回答
  •  盖世英雄少女心
    2021-01-01 03:46

    You can create a dedicated shell for use with your project, and avoid installing the runtime globally/for current user.

    Example of minimal nix shell for Elixir on Erlang/OTP 20:

    The contents of default.nix file:

    with import  {};
    
    stdenv.mkDerivation rec {
        name = "env";
        env = buildEnv { name = name; paths = buildInputs; };
        buildInputs = [
            beam.packages.erlangR20.elixir
            inotify-tools
        ];
    }
    

    Then in terminal, navigate to the directory where default.nix is saved, and invoke nix-shell. You should drop into a shell which has iex and mix available.

提交回复
热议问题