Skip to content

Instantly share code, notes, and snippets.

@geofft
Created September 24, 2024 19:15
Show Gist options
  • Select an option

  • Save geofft/e7e9144380bbad7479d16cb39968cf44 to your computer and use it in GitHub Desktop.

Select an option

Save geofft/e7e9144380bbad7479d16cb39968cf44 to your computer and use it in GitHub Desktop.
Building TartanLlama/sdb via Nix

Quick setup instructions for building the code from Sy Brand's Building a Debugger on a machine with a working Nix installation. (There are many other perfectly good ways to get set up; if you don't already have Nix you might prefer to do something else.)

For Recursers, you can get to a machine with Nix by configuring your SSH key, waiting an hour or two, and doing ssh broome.cluster.recurse.com.

The author's worked source code is available on GitHub, so if you want to start partway through the book, do e.g.

git clone https://github.com/TartanLlama/sdb -b chapter-8
cd sdb

Or just start in chapter 1. Then create the following file as shell.nix:

let
  nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-24.05";
in
with import nixpkgs {};
mkShell {
  packages = [
    cmake
    vcpkg
  ];
  shellHook = ''
    export CMAKE_TOOLCHAIN_FILE=${vcpkg}/share/vcpkg/scripts/buildsystems/vcpkg.cmake
  '';
}

Then run

nix-shell
mkdir build
cd build
cmake ..
cmake --build .

and now you can e.g.

tools/sdb cat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment