Dash lands in NixOS 20.03

Starting with the release of NixOS 20.03, Dash from Plotly (Github project) is now part of the system's Python packages. See my pull request for details.

Getting started

nix-shell

You can hop into a reproducible development environment with nix-shell:


[:~]$ nix-shell -p 'python37.withPackages(ps: with ps; [ pandas dash ])'
[nix-shell:~]$ python app.py

nix-build

One can build a Dash app server in a reproducible manner using Nix. Every dependency is cryptographically pinned down to the Python interpreter, glibc and openblas.

Here's an example build file `default.nix` that take a single file Dash app in file `app.py` and produce an executable:

let
  nixpkgs = builtins.fetchGit {
      name = "nixos-20.03";
      url = "https://github.com/nixos/nixpkgs-channels/";
      # `git ls-remote https://github.com/nixos/nixpkgs-channels nixos-20.03`
      ref = "refs/heads/nixos-20.03";
      rev = "ab3adfe1c769c22b6629e59ea0ef88ec8ee4563f";
  };
  pkgs = import nixpkgs {};

  python = pkgs.python37.withPackages(ps: with ps; [ pandas dash ]);
in
pkgs.stdenv.mkDerivation {
    name = "dash";
    src = ./.;
    buildInputs = [python];

    installPhase = ''
      mkdir -p $out/bin
      echo -e "#!/bin/sh\n\n${python.interpreter} $src/app.py" > $out/bin/server
      chmod +x $out/bin/server
    '';
}

you can then run the server:

$ result/bin/server

Using Nix tools, we can easily inspect all the dependencies (ie. the closure) of the `server` executable derived above:

  • nix
  • software
  • linux
  • plotly