1

Every time I install Erlang, I end up without 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:

  • 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. BEAM Languages (Erlang, Elixir & LFE) section (Version 19.09.1484.84586a4514d) does not mention Observer at all. It has a fairly recent update by DianaOlympos that does mention it, albeit I tried all these packages, but no joy:

Many Erlang/OTP distributions available in beam.interpreters have versions with ODBC and/or Java enabled or without wx (no observer support). 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.

Shane Sveller pointed it out that the wxGTK package needs to be set up using propagatedBuildInputs, but not sure how to do that. (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.)

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...


update: Apparently, it works somewhere out of the box. (Probably on NixOS.)

toraritte
  • 6,300
  • 3
  • 46
  • 67

2 Answers2

2

I have an overwrite for erlang, such that wx support is enabled:

{ 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:

$ 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). To find the right package for your OS, here are the available wx packages.

toraritte
  • 6,300
  • 3
  • 46
  • 67
  • Thanks! In the end, the solution is way more mundane, but accepted your answer because it is very educational on how to write a `nix-shell` script. – toraritte Dec 09 '19 at 20:41
  • Edited your answer to make the `wx` packages part of the `optionals` too, but was only able to try out the Linux-side of things. If you don't agree with any of the changes, just nix mine. Thanks again! (For reference to future self: see sections _5.1.5.17. lib.lists.optional_ and _5.1.5.18. lib.lists.optionals_ in the [Nixpkgs Manual](https://nixos.org/nixpkgs/manual/)). – toraritte Dec 09 '19 at 21:03
1

Kind of ashamed to admit that I am an idiot, but Observer was there all this time (along with net_adm)...

For some reason, it wouldn't autocomplete on the erl shell, but once observer:start(). was typed in and executed, it would recognize the module, and provide a list of available functions when hitting the Tab key.

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.

toraritte
  • 6,300
  • 3
  • 46
  • 67