A web UI for the nix store (early beta)

I’m working on an open source, nix-based CI system called Gorgon, and one of the components of that is a web UI for the nix store - right now, it just shows you derivations and logs, but in the future, it’ll be able to show live logs and builds as well.

With the latest nixpkgs-unstable, you can install it with:

{ pkgs, ... }:

{
  systemd.packages = with pkgs; [ nix-web ];

  systemd.sockets.nix-web = {
    socketConfig.ListenStream = "[::1]:8649"; # 8649 = 8000 + "NIX".
    wantedBy = [ "sockets.target" ];
  };
}

…and then look up a derivation: http://localhost:8649/nix/store/giidrg634mmaz212a21g34z1zaswl7qs-nix-web-0.1.0

This is an early beta, the code is a bit messy right now, and rendering a derivation with a lot of dependencies is currently very slow - but I have something in the works to fix that.

Feedback appreciated, either here, in our IRC channel: #gorgon-ci on hackint, or via Matrix: #gorgon-ci:hackint.org.

https://codeberg.org/gorgon/gorgon/src/branch/main/nix-web

46 Likes

Really cool! (I took it for a quick spin when I saw the nixpkgs PR.)

4 Likes

I just got v0.4.0 out (available now in nixpkgs!), with a big internal change: it no longer invokes the nix CLI. Instead, I built a crate called nix-daemon, which lets it speak the daemon protocol directly.

This has two big upsides:

  1. The output from the nix CLI is not stable, and we’ve already had it make a breaking change once.

    Meanwhile, the nix-daemon protocol is versioned, and new versions of Nix will gracefully downgrade to an older protocol with no issues.

  2. It’s orders of magnitude faster.

    Calling the nix CLI recursively makes render time scale really badly with the number of inputs, and while this was fine for simpler derivations, more complex ones (such as the result of a nixos-rebuild on my laptop) would take minutes to render.

    Most derivations now render in milliseconds, and my nixos-rebuilds are down to a few seconds.

However, it also has two downsides: it no longer works with daemonless stores (hard to fix, it’s a completely different code path), and the nix-daemon crate currently only supports Nix 2.15 and later - adding support for Nix 2.3 is a high priority task, though, I know how many of you use it. It’s also tested in CI against all versions of Lix.

The nix-daemon crate is also just something I’ve wanted to write for a while now, and I hope someone will find it useful on its own!

12 Likes