Consider this simple debian package: wolframscript.deb (to inspect you'll have to click the download link for Linux). After unpacking, it has the following file structure:

├── opt
│   └── Wolfram
│       └── WolframScript
│           └── bin
│               └── wolframscript
└── usr
    ├── local
    │   └── share
    │       └── man
    │           └── man1
    │               └── wolframscript.1
    └── share
        ├── icons
        │   └── hicolor
        │       ├── 128x128
        │       │   └── mimetypes
        │       │       └── application-vnd.wolfram.wls.png
        │       ├── 32x32
        │       │   └── mimetypes
        │       │       └── application-vnd.wolfram.wls.png
        │       └── 64x64
        │           └── mimetypes
        │               └── application-vnd.wolfram.wls.png
        └── mime
            └── packages
                └── application-vnd.wolfram.wls.xml

The only relevant file is the opt/Wolfram/WolframScript/bin/wolframscript binary (I think). I tried executing this plainly but I get a bash: ./wolframscript: No such file or directory error. How do I make this binary/package usable in NixOS?

EDIT: To answer @muru's question:

$ file opt/Wolfram/WolframScript/bin/wolframscript
opt/Wolfram/WolframScript/bin/wolframscript: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib
$ ldd opt/Wolfram/WolframScript/bin/wolframscript
        linux-vdso.so.1 (0x00007fff767c9000)
        libpthread.so.0 => /nix/store/7gx4kiv5m0i7d7qkixq2cwzbr10lvxwc-glibc-2.27/lib/libpthread.so.0 (0x00007f55b8525000)
        librt.so.1 => /nix/store/7gx4kiv5m0i7d7qkixq2cwzbr10lvxwc-glibc-2.27/lib/librt.so.1 (0x00007f55b831d000)
        libdl.so.2 => /nix/store/7gx4kiv5m0i7d7qkixq2cwzbr10lvxwc-glibc-2.27/lib/libdl.so.2 (0x00007f55b8119000)
        libstdc++.so.6 => not found
        libm.so.6 => /nix/store/7gx4kiv5m0i7d7qkixq2cwzbr10lvxwc-glibc-2.27/lib/libm.so.6 (0x00007f55b7d84000)
        libgcc_s.so.1 => /nix/store/7gx4kiv5m0i7d7qkixq2cwzbr10lvxwc-glibc-2.27/lib/libgcc_s.so.1 (0x00007f55b7b6e000)
        libc.so.6 => /nix/store/7gx4kiv5m0i7d7qkixq2cwzbr10lvxwc-glibc-2.27/lib/libc.so.6 (0x00007f55b77ba000)
        /lib64/ld-linux-x86-64.so.2 => /nix/store/7gx4kiv5m0i7d7qkixq2cwzbr10lvxwc-glibc-2.27/lib64/ld-linux-x86-64.so.2 (0x00007f55b874400
  • 1
    What do file opt/Wolfram/WolframScript/bin/wolframscript and ldd opt/Wolfram/WolframScript/bin/wolframscript report? – muru May 23 '19 at 16:49
  • @muru I added this to my question. – George May 23 '19 at 17:09
  • So your no-such-file error is due to the missing libstdc++ library. Install that and the file should be good to go. – muru May 23 '19 at 17:23
  • @muru: Since I run NixOS this is not so straightforward. – George May 23 '19 at 17:24
  • 1
    Dunno about NixOS, but libstdc++ is a very commonly used library - most C++ programs would need it. Maybe nixos.org/nix-dev/2016-August/021431.html would be of help. – muru May 23 '19 at 17:28

I presented here a full list of methods to solve your problem, with example files. The two more efficient methods are autoPatchelfHook (prefered, as Vladimír Čunát was suggesting), or eventually steam-run (based on buildFHSUserEnv with lot's of default libraries) when you mostly want a quick-and-dirty-fix.

Here is a quick summary:

Proper method with autoPatchelfHook

NixOs did for us a special "hook" autoPatchelfHook that automatically patches everything for you! You just need to specify it in (native)BuildInputs, and nix does the magic. Put in derivation.nix:

{ stdenv, dpkg, glibc, gcc-unwrapped, autoPatchelfHook }:

  # Please keep the version x.y.0.z and do not update to x.y.76.z because the
  # source of the latter disappears much faster.
  version = "12.0.0";

  src = ./WolframScript_12.0.0_LINUX64_amd64.deb;

in stdenv.mkDerivation {
  name = "wolframscript-${version}";

  system = "x86_64-linux";

  inherit src;

  # Required for compilation
  nativeBuildInputs = [
    autoPatchelfHook # Automatically setup the loader, and do the magic

  # Required at running time
  buildInputs = [

  unpackPhase = "true";

  # Extract and copy executable in $out/bin
  installPhase = ''
    mkdir -p $out
    dpkg -x $src $out
    cp -av $out/opt/Wolfram/WolframScript/* $out
    rm -rf $out/opt

  meta = with stdenv.lib; {
    description = "Wolframscript";
    homepage = https://www.wolfram.com/wolframscript/;
    license = licenses.mit;
    maintainers = with stdenv.lib.maintainers; [ ];
    platforms = [ "x86_64-linux" ];

and in default.nix:

{ pkgs ? import <nixpkgs> {} }:

pkgs.callPackage ./derivation.nix {}

compile and run with


Quicker method, with steam-run

Nix provides buildFHSUserEnv that fakes a classic linux. You can use it directly and add the libraries to it, or if you prefer steam-run contains already lot's of libraries (despite the name it's independent of steam). Note that this method is heavier and requires a longer startup, so avoid it when it's possible.

You just need to install steam-run (you need to allow unfree softwares, with { allowUnfree = true; } in ~/.config/nixpkgs/config.nix or if you use nixos-rebuild, use in your configuration.nix the line nixpkgs.config.allowUnfree = true;), and then run:

steam-run ./wolframscript

Fore more details, see Different methods to run a non-nixos executable on Nixos

| improve this answer | |
  • I don't know. I +1'ed it and am reading it now. – George Jun 7 '19 at 0:14

I expect it will be best to create a simple nix expression that has this deb as input, unpacks it etc. so you have this installed "in nix way" (e.g. dependencies won't be deleted before the path itself). When you do that, adding autoPatchelfHook into buildInputs should fix these missing references.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.