osquery extension exposing nix_system_packages and nix_user_packages virtual tables on NixOS hosts.
  • Go 68.5%
  • Nix 31.5%
Find a file
Lucas Pick 72d77cc07c flake: allow extension to bind its own socket in orbit's state dir
osquery-go's extension manager creates its own UNIX socket at
  <orbit-socket>.<random> adjacent to orbit's. With ProtectSystem=
  strict, /var/lib/orbit/ was read-only and bind() failed with
  "read-only file system". Add ReadWritePaths for the directory
  the extension socket lives in (derived from extensionsSocket).

  Observed on framepick after first activation — service crash-
  looped with "listen unix /var/lib/orbit/orbit-osquery.em.NNNNN:
  bind: read-only file system".
2026-06-18 13:53:36 -05:00
vendor osquery-nix-tables: initial extension + flake.nix + NixOS module 2026-06-18 11:28:37 -05:00
.gitignore osquery-nix-tables: initial extension + flake.nix + NixOS module 2026-06-18 11:28:37 -05:00
flake.nix flake: allow extension to bind its own socket in orbit's state dir 2026-06-18 13:53:36 -05:00
go.mod osquery-nix-tables: initial extension + flake.nix + NixOS module 2026-06-18 11:28:37 -05:00
go.sum osquery-nix-tables: initial extension + flake.nix + NixOS module 2026-06-18 11:28:37 -05:00
main.go osquery-nix-tables: initial extension + flake.nix + NixOS module 2026-06-18 11:28:37 -05:00
main_test.go osquery-nix-tables: initial extension + flake.nix + NixOS module 2026-06-18 11:28:37 -05:00
README.md osquery-nix-tables: initial extension + flake.nix + NixOS module 2026-06-18 11:28:37 -05:00

osquery-nix-tables

osquery extension exposing Nix package information as SQL-queryable virtual tables.

Tables

nix_system_packages

Walks /run/current-system/sw/bin/ symlinks, parses each resolved store path. Reports the unique set of packages backing the system PATH (i.e. environment.systemPackages from configuration.nix).

Column Type Description
name text Derivation name (e.g., git, coreutils-full)
version text Version segment (e.g., 2.53.0), may include -bin etc.
store_path text Full /nix/store/<hash>-<name>-<version> directory
hash text 32-char nix store hash
binary_count integer Number of symlinks under bin/ pointing at this store path

nix_user_packages

Same shape as nix_system_packages, with an extra user column. Walks /etc/profiles/per-user/<user>/bin/ for every user that has a profile (typically home-manager-managed).

Usage

Standalone (test against osqueryi)

nix build
sudo ./result/bin/osquery-nix-tables --socket /tmp/osquery.em &
osqueryi --extension /tmp/osquery.em
osquery> SELECT name, version FROM nix_system_packages ORDER BY name LIMIT 10;

As a NixOS module alongside orbit

Add as a flake input:

inputs.osquery-nix-tables.url = "git+https://code.grail.tiberius.com/tiberius-grail/osquery-nix-tables";

Import the module and enable:

{
  imports = [ inputs.osquery-nix-tables.nixosModules.default ];
  services.osquery-nix-tables.enable = true;
}

The systemd service binds to orbit.service — starts after orbit creates its osqueryd extensions socket, restarts when orbit does, stops when orbit does. Runs as root (orbit's socket is owner-only writable).

In fleet's UI, the new tables show up in Reports / per-host query runs:

SELECT name, version FROM nix_system_packages ORDER BY name;

Development

go test ./...
nix build

vendor/ is checked in (vendorHash = null in flake.nix) — no network at build time, matches the grail-fleet-proxies convention.