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

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

    Glad I posted this question back then because the answers are terrific, but since then I realized that there is no real point in installing interpreters (especially because sometimes multiple versions are needed), so just use nix-shell on demand.

    For the current version in the active channel:

    nix-shell -p erlang
    

    For other versions not in the current channel, a specific channel can be given:

    nix-shell -I nixpkgs=channel:nixos-unstable -p erlangR22
    

    Or add path to the Nix expression in your NixOS/nixpkgs clone:

    $ nix-shell -I nixpkgs=~/clones/nixpkgs -p erlangR23
    

    How to find packages with attribute paths on the console

    $ nix-env -qaP 'erlang*'
    # ...
    nixos.erlangR20            erlang-20.3.8.9
    nixos.erlangR21            erlang-21.3.8.3
    nixos.erlang               erlang-22.1.7
    # ...
    
    $ nix-env -f ~/clones/nixpkgs/ -qaP 'erlang*'
    # ...
    nixos.erlangR20            erlang-20.3.8.9
    nixos.erlangR21            erlang-21.3.8.3
    nixos.erlang               erlang-22.1.7
    # ...
    === >>> erlangR23            erlang-23.0.2  <<<====
    

    This answer goes more into the details.

提交回复
热议问题