Conversation
Tables now hold `TableCell` values (content + alignment) instead of bare strings, and `printTable()` accepts a max width that truncates lines via `filterANSIEscapes`. The implicit `TableCell(std::string)` constructor keeps existing callers working; `nix-env --query` is updated to use the new `TableRow` alias. This prepares the table utility for `nix ps`, which needs right-aligned numeric columns and terminal-width-aware output.
Returns the terminal's column count, or `numeric_limits<unsigned int>::max()` when unknown. Lets callers ask for a usable width directly instead of unpacking `getWindowSize()` and special-casing zero.
Adds a new `nix ps` command that lists active builds along with their process trees and CPU usage. This is upstreamed from Determinate Nix. The implementation: * `ActiveBuild` / `ActiveBuildInfo` describe a running build; `LocalStore` persists one JSON file per active build under `$NIX_STATE_DIR/active-builds`, holding a write lock to denote liveness. `DerivationBuilderImpl` registers/unregisters via an RAII `BuildHandle`. * `QueryActiveBuildsStore` is a new store mixin; `LocalStore` walks `active-builds/` and enriches each entry with per-process info from `/proc` (Linux) or `proc_pidinfo`/`sysctl` (macOS), and cgroup CPU stats when a cgroup is available. * `RemoteStore` proxies the query over a new `WorkerProto::Op::QueryActiveBuilds` (op 48), gated on the `queryActiveBuilds` feature flag. * New `getPidsInCgroup()` helper enumerates the PIDs in a cgroup. * `nix ps` renders a tree-formatted table with right-aligned CPU column, truncated to terminal width on a TTY. `--json` emits the raw `ActiveBuildInfo` array.
Starts a build that backgrounds a `sleep 600` and blocks on a fifo, then asserts that `nix ps` (text and `--json`) reports the running derivation and its two-level process tree (builder shell + sleep child), and that the list becomes empty once the build finishes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
Would it be much work to add memory usage? The biggest issue I have with mass nixpkgs rebuilds isn't CPU but running out of memory, observability into that would be awesome especially for downstream tools that could consume it and process it, e.g., determine the maximum memory per CPU usage of a derivation for resource management purposes. Edit: Actually, I can work on this, I'll put up a PR against this branch when it's working. |
Contributor
|
When run in sudo mode and there are ongoing builds, it'll hang on "waiting for exclusive access to the Nix store" (but you have to use |
andrewgazelka
added a commit
to indexable-inc/index
that referenced
this pull request
Jul 7, 2026
…fix to catch (BaseError&) (#2021) Follow-through on the stopped NixOS/nix upstreaming wave. ## What changed **`lib/fork-packages.nix` — nix `upstreamPolicy`** - `aiPrsAllowed = "false"`, citing [NixOS/nix#15984](NixOS/nix#15984) and its three operative constraints: human-authored PR communication, no unreviewed automated submissions, `Assisted-by:` disclosure trailer. `upstream-sync` now refuses to open any nix PR at the repo level. **Patch intent — all nix patches flipped `attempt` → `hold`** - `0001` (GC-roots daemon crash): reworked to `catch (BaseError&)` (the narrowing proposed in [#15963](NixOS/nix#15963) after xokdvium objected to `catch (...)`); a human resubmits. - `0002` (lookup-path EPERM eval fix): cleanest candidate, framed as restoring the EPERM-tolerant path probing of [#8240](NixOS/nix#8240) lost in the `std::filesystem` migration (see #5884, still-open #8485); a human submits. - `0003-0009` (build-status series): engage on edolstra's active [#15979](NixOS/nix#15979) (`nix ps`) instead of filing a competing series. **Patch rework + disclosure** - `packages/nix/nix/patches/0001` reworked (`catch (BaseError&)`, concise comment addressing xokdvium's "too verbose" note). - `Assisted-by: Claude <noreply@anthropic.com>` trailers added to `0001` and `0002` commit messages, regenerated deterministically via `git format-patch --zero-commit --no-signature --no-stat -N`. Build-status series bytes unchanged. - `upstream-status.json` regenerated (`nix run .#upstream-sync -- nix`): all nine now `hold`. **Incidental unblock** - `packages/nu-py/python/nu/__init__.py`: `os.getcwd()` → `Path.cwd()` — a pre-existing ruff PTH109 failure on main (from #1999) that blocked the pre-commit lint for every subsequent commit. ## Validation - `checks.aarch64-darwin.patched-src-nix` — green (all 9 patches apply, incl. reworked 0001). - `checks.aarch64-darwin.patch-dag-nix` — `OK (9 patches, 0 edges)`. - `nix run .#upstream-sync -- nix --dry-run` — plans **nothing** outward: all 9 patches `[skip]`, repo-level block reported, no `would-open`/`attempt-ready`. - Full `nix-ix` package build (validates the reworked C++ compiles) — running. ## Machinery gaps filed as issues - #2016 — semantic duplicate detection (title-token search missed #15979 vs our build-status subjects). - #2017 — series grouping (empty DAG deps ⇒ closure grouping never engages). - #2018 — `Assisted-by` commit-trailer support as policy-driven disclosure. ## Human handoff Ready-to-send PR drafts (0001, 0002) and the #15979 comment are in `~/Projects/indexable-inc/nix-upstream-handoff.html` for Andrew as the accountable submitter. **No PRs are filed on NixOS/nix by this change** — the kit is for a human to submit. Prepared with AI assistance (Claude); directed and reviewed by a human maintainer. <!-- Macroscope's pull request summary starts here --> <!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. --> <!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. --> > [!NOTE] > ### Hold all NixOS/nix upstreaming and rework GC-roots patch to catch `BaseError&` > - Sets `aiPrsAllowed` to `false` in the upstream policy for NixOS/nix, blocking automated PR creation against that repo per [NixOS/nix#15984](NixOS/nix#15984). > - Changes all nine patch entries in [fork-packages.nix](https://github.com/indexable-inc/index/pull/2021/files#diff-35e5ff5b02c2dcd32c93fd770ad2194f9fcbfc9f35fdcbd56821891b6e7452f4) and [upstream-status.json](https://github.com/indexable-inc/index/pull/2021/files#diff-9407ed440a363a47ae2dbcca49731c8db3d7dfe38943d75473dd0f5c4fec28eb) from `attempt` to `hold`, deferring upstreaming to humans. > - Reworks [0001-fix-libstore-don-t-crash-the-daemon-when-a-GC-roots-.patch](https://github.com/indexable-inc/index/pull/2021/files#diff-2a703db65303f7f7d269ae802072e8f5e4a984d141b3ab175452f2051dd5d197) to catch `BaseError&` instead of `Error&`, so `Interrupted` exceptions no longer escape the GC client-root thread and crash the daemon; removes the earlier blanket `catch(...)` block. > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized 00a7768.</sup> > <!-- Macroscope's review summary ends here --> > <!-- macroscope-ui-refresh --> <!-- Macroscope's pull request summary ends here -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
nix psshows active builds, e.g.This improves the observability of a Nix system.
It's implemented by having Nix keep track of the root PIDs of active builds in
/nix/var/nix/active-builds/and adding a daemon protocol operation for querying active builds and their CPU stats (so this also works over ssh-ng stores).Taken from Determinate Nix (mostly DeterminateSystems#282).
Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.