From 9e324dcfb8ca4a0d0b54a20ca5a6e663e23a48ca Mon Sep 17 00:00:00 2001 From: Yan Date: Mon, 19 Oct 2026 14:01:02 -0700 Subject: [PATCH] Add a Nix flake. Builds srcdump with rustPlatform and wraps it so nixpkgs' uv is on PATH, so srcdump doesn't need to download uv itself. Also provides a dev shell with the Rust toolchain and uv. Co-Authored-By: Claude Opus 5.5 --- .gitignore | 1 + README.md | 9 ++++++++ flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 136 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 1bb9b0a..27d5428 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target /core /dist +/result diff --git a/README.md b/README.md index a016891..a183707 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,15 @@ We provide two types of releases for Windows (x64), Linux (x86-64 and arm64), an "slim", which only contains the `srcdump` main executable. It will download uv and angr (as well as its dependencies) during runtime (requires Internet connection). "full", which contains srcdump, uv, and a bundled virtual environment of angr (does not require Internet connection during runtime). +### Nix + +srcdump can be built or run with Nix flakes. The package puts nixpkgs' uv on `PATH`, and srcdump provisions angr with it on first run. + +``` +$ nix run github:angr/srcdump -- ./program +$ nix develop # shell with the Rust toolchain and uv +``` + ## How it works srcdump is a thin orchestrator written in Rust. diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..9f6b98c --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1791914995, + "narHash": "sha256-Zf/xfQEAasnwnmEfHqW/4hjDE/s44yn2hD4RuVIZRjA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b7a79d3fea1e214f6d668d521cecec0c01e26544", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1792094642, + "narHash": "sha256-zp8ToDMnqZcu4o4IH9pdwXFXGp7yLm/M0dEnNWnyd7I=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fe13242281a67641c0102cdb1087f0ebe586c7df", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..4480bab --- /dev/null +++ b/flake.nix @@ -0,0 +1,65 @@ +{ + description = "srcdump: an objdump-like tool that prints decompiled code, backed by angr"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = + { + self, + nixpkgs, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); + + # srcdump itself. At runtime it provisions angr with uv, so put + # nixpkgs' uv on PATH instead of letting srcdump download one. + srcdump = pkgs.rustPlatform.buildRustPackage { + pname = "srcdump"; + inherit (cargoToml.package) version; + + src = pkgs.lib.cleanSource ./.; + cargoLock.lockFile = ./Cargo.lock; + + nativeBuildInputs = [ pkgs.makeWrapper ]; + + postInstall = '' + wrapProgram $out/bin/srcdump \ + --suffix PATH : ${pkgs.lib.makeBinPath [ pkgs.uv ]} + ''; + + meta = { + inherit (cargoToml.package) description homepage; + license = pkgs.lib.licenses.bsd2; + mainProgram = "srcdump"; + }; + }; + in + { + packages = { + inherit srcdump; + default = srcdump; + }; + + apps.default = flake-utils.lib.mkApp { drv = srcdump; }; + + devShells.default = pkgs.mkShell { + inputsFrom = [ srcdump ]; + packages = with pkgs; [ + cargo + rustc + rustfmt + clippy + rust-analyzer + uv + ]; + }; + } + ); +}