Zombie Zen

Ross's Blog

A SQLite Notebook

Posted at by Ross Light

Similar to the Jupyter kernel for Ivy I hacked up a few months ago, I’ve created a SQLite kernel for Jupyter Notebook.

Screenshot of a SQLite Visual Studio Code notebook.

Screenshot of a SQLite Visual Studio Code notebook.

Check out the demo on GitHub! (Installation is a little DIY if you’re not using Nix, but there are instructions in the README on how to build.) Read on if you’re interested in how it works.

Read more…
Posted at
Permalink

Impure Nix Derivations

Posted at by Ross Light

I’ve been writing about Nix for a few years now, and it has become a staple for all my personal projects. It solves the thorny problem of setting up reproducible development environments in a flexible and general way, while still allowing me to use my tooling the way I want to. I no longer have to worry about my GitHub Actions having different versions of tools from my local dev environment, which is a huge relief.

I’ve started making my CI jobs use nix flake check, which lets me write and run my CI checks using Nix syntax, further removing any differences between local development and CI. However, I sometimes have tests that want to use the network, which usually isn’t allowed. I recently discovered that you can use __impure = true; to remove the networking sandbox:1

# flake.nix
{
  inputs = {
    nixpkgs.url = "nixpkgs";
  };

  outputs = { nixpkgs, ... }: {
    checks.x86_64-linux.foo =
      let
        pkgs = import nixpkgs { system = "x86_64-linux"; };
      in pkgs.stdenvNoCC.mkDerivation {
        name = "foo-check";
        src = ./.;
        __impure = true;
        nativeBuildInputs = [
          pkgs.cacert
          pkgs.curl
        ];
        buildPhase = ''
          runHook preBuild
          curl -fsSL https://example.com/ > /dev/null
          runHook postBuild
        '';
        installPhase = ''
          runHook preInstall
          touch "$out"
          runHook postInstall
        '';
      };
  };
}

For this to work, you must also set extra-experimental-features = impure-derivations ca-derivations in /etc/nix/nix.conf.2 Just passing a command-line argument doesn’t seem to work in my usage with Nix 2.13.3 in a multi-user installation.

Since this feature is still experimental, it’s not widely advertised or documented. Hopefully this helps you use it for your own tests.

Posted at
Permalink

An Ivy Notebook

Posted at by Ross Light

I hacked out a Jupyter kernel for Rob Pike’s ivy language, an APL-like desk calculator. This allows using Ivy expressions inside a Jupyter notebook and inside Visual Studio Code’s notebooks feature. It’s got rough edges, but it’s good enough for me to quickly do calculations without leaving Visual Studio Code.

Screenshot of a Jupyter notebook with the Ivy demo.

Screenshot of a Jupyter notebook with the Ivy demo.

The source is up on GitHub. (Installation is a little DIY if you’re not using Nix, but it should go build if you have libzmq installed locally.)

Read more…
Posted at
Permalink

Connecting Bash to Nix

Posted at by Ross Light

Julia Evans wrote a toot asking:

are there any guides to nix that start from the bottom up (for example starting with this bash script https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh) and then working up the layers of abstraction) instead of from the top down?

I realized that despite the title, my blog post Nix From the Ground Up misses the mark on providing this type of explanation. While I do think the Nix language is the lowest abstraction layer to learn Nix, I wanted to zoom in on the core derivation abstraction through a tutorial. This way, we can better understand how Nix derivations relate to Bash scripts.

Read more…
Posted at
Permalink

TIL: SQLite Virtual Tables

Posted at by Ross Light

I’ve been working on implementing virtual tables for my zombiezen.com/go/sqlite package. I hadn’t used virtual tables in SQLite before this, so to get a feel for the API, I played around with the feature and read up on the documentation. Since it’s not a feature I’ve seen talked about a lot, I wanted to share what virtual tables are, why you might want to use them, and what some limitations are.

Read more…
Posted at
Permalink
← Previous Page Next Page →