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

前端 未结 3 425
被撕碎了的回忆
被撕碎了的回忆 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:34

    You are on the right track; there is no need to start over.

    To install the package from nix repl you can use the :i command.

    nix-repl> :i pkgs.beam.packages.erlangR21.elixir
    

    This will install the package into your ~/.nix-profile where it will be in $PATH, so you can call it. It is equivalent to running

    nix-env -iA nixpkgs.beam.packages.erlangR21.elixir
    

    nix-store -r (or equivalently, nix-store --realise) is considered a very low-level tool. It can only create a symlink to a package and that is rarely what you want. It doesn't even create a garbage collection root by default, so if you garbage collect, the symlink will become broken.

    Although nix-env -iA is a valid way of installing software, you may consider ~/.nix-profile global state and avoid it for that reason. It seems to me like elixir that is more tied to a project, rather than to your user. For example you may want to use distinct versions for some projects and it may make sense to share your development tools with others who work on a project. That is you can use nix-shell for. Here's an example of shell.nix.

提交回复
热议问题