简体   繁体   English

如何使用 Nix 包管理器通过 Observer 安装 Erlang 或 Elixir?

[英]How to install Erlang or Elixir with Observer using the Nix package manager?

Every time I install Erlang, I end up without Observer.每次我安装 Erlang 时,我最终都没有 Observer。 Used the commands below on a Ubuntu laptop with Xmonad and a Debian 9 running in the cloud , and seemingly they both resulted in the same package being installed:带有 Xmonad在云中运行Debian 9Ubuntu 笔记本电脑上使用以下命令,似乎它们都导致安装了相同的软件包:

  • nix-env -iA pkgs.beam.packages.erlangR22
  • nix-env -iA nixpkgs.beam.interpreters.erlang
  • nix-env -iA nixpkgs.beam.interpreters.erlangR22_odbc_javac

The Nixpkgs manuals 15.2. Nixpkgs 手册 15.2。 BEAM Languages (Erlang, Elixir & LFE) section (Version 19.09.1484.84586a4514d) does not mention Observer at all. BEAM Languages (Erlang, Elixir & LFE) 部分(版本 19.09.1484.84586a4514d)根本没有提到观察者。 It has a fairly recent update by DianaOlympos that does mention it, albeit I tried all these packages, but no joy: DianaOlympos在最近的更新中确实提到了它,尽管我尝试了所有这些软件包,但并不高兴:

Many Erlang/OTP distributions available in beam.interpreters have versions with ODBC and/or Java enabled or without wx (no observer support).许多在beam.interpreters可用的 Erlang/OTP 发行beam.interpreters都有启用 ODBC 和/或 Java 或不启用 wx(不支持观察者)的版本。 For example, there's beam.interpreters.erlangR22_odbc_javac , which corresponds to beam.interpreters.erlangR22 and beam.interpreters.erlangR22_nox , which corresponds to beam.interpreters.erlangR22 .例如,有beam.interpreters.erlangR22_odbc_javac对应于beam.interpreters.erlangR22beam.interpreters.erlangR22_nox对应于beam.interpreters.erlangR22

Shane Sveller pointed it out that the wxGTK package needs to be set up using propagatedBuildInputs , but not sure how to do that. 巴蒂尔Sveller指出来的是, wxGTK包需要进行设置使用propagatedBuildInputs ,但不知道该怎么做。 (Simply just installing wxGTK then Erlang doesn't work of course; was naive enough to try it. Also found out that chapter 20 of Nix Pills is exactly about this topic.) (只是简单地安装wxGTK然后 Erlang 当然不起作用;尝试它是天真的。还发现Nix Pills 的第 20 章正是关于这个主题。)

This is also kind of a follow-up to the question " How to install Erlang/Elixir on a non-NixOS system? ", but I didn't realize it then that Observer is missing...这也是问题“如何在非 NixOS 系统上安装 Erlang/Elixir? ”的后续问题,但当时我没有意识到 Observer 丢失了......


update: Apparently, it works somewhere out of the box .更新:显然, 它可以在某处开箱即用 (Probably on NixOS.) (可能在 NixOS 上。)

I have an overwrite for erlang, such that wx support is enabled:我对 erlang 进行了覆盖,以便启用 wx 支持:

{ pkgs ? import <nixpkgs> {} }:

with pkgs;

let
  inherit (lib) optionals;

  erlang_wx = erlangR21.override {
    wxSupport = true;
  };

  elixir = (beam.packagesWith erlang_wx).elixir.override {
    version = "1.9.2";
    rev = "ffe7a577cc80f37381dc289c820842d346002364";
    sha256 = "19yn6nx6r627f5zbyc7ckgr96d6b45sgwx95n2gp2imqwqvpj8wc";
  };
in

mkShell {
  buildInputs = [ elixir git ]

    # For file_system on Linux.
    ++ optionals stdenv.isLinux [ inotify-tools wxGTK ]

    # For file_system on macOS.
    ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
      # For file_system on macOS.
      CoreFoundation
      CoreServices
      wxmac
    ]);
}

Save this (as shell.nix for example), and just run it:保存它(例如shell.nix ),然后运行它:

$ nix-shell shell.nix

# or, if you are in the same directory:
$ nix-shell

Works on my machine!在我的机器上工作!


Note: wxmac in buildInputs is specific to MacOS (and wxGTK to Linux).注: wxmacbuildInputs是特定于MacOS的(和wxGTK到Linux)。 To find the right package for your OS, here are the available wx packages .要为您的操作系统找到合适的软件包, 这里有可用的wx软件包

Kind of ashamed to admit that I am an idiot, but Observer was there all this time ( along with net_adm )...承认我是个白痴有点惭愧,但观察者一直在那里( net_adm )......

For some reason, it wouldn't autocomplete on the erl shell, but once observer:start().出于某种原因,它不会在erl shell 上自动完成,但是一旦observer:start(). was typed in and executed, it would recognize the module, and provide a list of available functions when hitting the Tab key.输入并执行后,它会识别模块,并在按 Tab 键时提供可用功能列表。

I probably messed up translating between iex and erl ( observer.start(). and other combinations), and I assumed that the resulting error message (together with no autocompletion) means that the module was missing.我可能搞砸了iexerlobserver.start().和其他组合)之间的转换,并且我认为产生的错误消息(连同没有自动完成)意味着模块丢失。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM