Skip to content

Add readdir primop - #235

Closed
shlevy wants to merge 2 commits into
NixOS:masterfrom
shlevy:readdir
Closed

shlevy wants to merge 2 commits into
NixOS:masterfrom
shlevy:readdir

Conversation

@shlevy

@shlevy shlevy commented Apr 1, 2014

Copy link
Copy Markdown
Member

This is useful for things like nix-make, and may make nixpkgs's organization cleaner

shlevy added 2 commits March 31, 2014 20:17
This is useful for things like nix-make, and may make nixpkgs's organization cleaner
@edolstra

edolstra commented Apr 1, 2014

Copy link
Copy Markdown
Member

It should be named readDirectory or readDir. Also, it should return an attribute set instead of a list. The value of the attributes could include the type of the file (see filterSource).

Also, I don't want to merge this until the use case is more concrete (how "may" it make Nixpkgs organization cleaner?).

@shlevy

shlevy commented Apr 7, 2014

Copy link
Copy Markdown
Member Author

The main use case I envisioned was for nix-make, similar to how you use wildcard in the nix makefiles. Basically defining a program or library as being composed of all of the c files in the current directory and having individual derivations generated for each and one for linking.

The nixpkgs organization thing was mostly about possibly getting rid of most of all-packages.nix, if we came up with a nice naming scheme for package directories, versioned expressions, etc. then we'd only need a list of overrides when the default callPackage foo {} fails.

@shlevy

shlevy commented Jun 10, 2014

Copy link
Copy Markdown
Member Author

@edolstra Does my explanation help?

@tailhook

Copy link
Copy Markdown
Contributor

+1 on this feature by itself. Also hope this will make enumeration of packages in all-packages.nix obsolete.

edolstra added a commit to NixOS/nixpkgs that referenced this pull request Jul 22, 2014
There are zillions of lines of the form

  foo = callPackage ../bla/foo { };

in all-packages.nix. To get rid of this verbosity, you can now list
such packages in pkgs/auto-packages.nix. This is just a list of
package file names, e.g.

  development/libraries/libogg
  development/libraries/libvorbis
  tools/archivers/gnutar

If the package needs non-default function arguments, or if its
intended attribute name is different from its file name, then you
cannot put it in auto-packages.nix and instead need to specify it in
all-packages.nix.

If Nix had a glob function (NixOS/nix#235), we
could even get rid of auto-packages.nix and have package expressions
be discovered automatically. However, that might not be desirable
because of the need to traverse the file system to find packages we
may not even use.
@shlevy shlevy closed this Aug 26, 2014
@shlevy shlevy mentioned this pull request Oct 1, 2014
zolodev pushed a commit to zolodev/nix that referenced this pull request Jan 1, 2024
…ser-0.17.0

chore(deps): bump myst-parser from 0.16.1 to 0.17.0
tebowy pushed a commit to tebowy/nix that referenced this pull request Jul 11, 2024
these should really wait for networks to come up, otherwise they can fail.

fixes NixOS#235

Change-Id: I08989e8bdb0de280df74660ac43983de5c34fa9d
P-E-Meunier pushed a commit to P-E-Meunier/nix that referenced this pull request Feb 26, 2025
…jects/dependency_issue_65/diesel-1.4.6

Bump diesel from 1.4.3 to 1.4.6 in /sample_projects/dependency_issue_65
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 25, 2026
… audit

The post-Batch-G adversarial audit asked whether claimed-unfiled
opportunities were genuinely untracked or sub-scope of existing
candidates. The auditor found three of my eight "unfiled" claims
were wrong — already covered by NixOS#190 (prim_fetchTree), NixOS#108
(mkLazyValueThunk), or NixOS#4/NixOS#57 (proto-helper macro hygiene). The
remaining five lacked tracking numbers and lived only in commit
bodies, FIXMEs, or buried Branch-line prose. File them as
proper candidate entries:

NixOS#234 — Store::signPathInfo / signRealisation re-read every
  secret-key file from disk on every signing call. NixOS#100's
  helper-only landing intentionally excluded the cache; the
  FIXME comment in store-api.cc is the canonical pointer but
  no candidate tracked the lift. Filed in
  12-libutil-libstore-core-extras.md.

NixOS#235 — addPermRoot GC-root-naming has three behavioural
  divergences across the two legacy CLI sites that NixOS#91's helper
  extraction deliberately left unresolved (counter-increment
  timing, absPath timing, printGCWarning gating). NixOS#91's Branch
  line names the deferral but no separate candidate tracked
  the audit work needed before substitution. Filed in
  11-legacy-cli.md.

NixOS#236 — CmdHash is the only getCommandsFor-eligible
  NixMultiCommand that can't migrate without a registry-with-
  args mechanism. NixOS#93's Branch line names this as deferred but
  no separate candidate tracked it. Two paths sketched: per-
  format subclass split or registry-with-args extension. Filed
  in 11-legacy-cli.md.

NixOS#237 — Two libstore call sites still use bare 65536 literals
  for I/O buffer sizing (local-store.cc::addToStoreFromDump
  and derivations.cc::Derivation::unparse) where NixOS#167's
  kDefaultIOBlockSize is the canonical name. Cross-shard,
  blocked on libutil upstream merge per Batch-E ledger. Now
  has a tracking number beyond the FOLLOWUPS-ledger entry.
  Filed in 17-cross-cutting.md.

NixOS#238 — GitArchiveInputScheme::isLocked carries an in-source
  FIXME proposing Git tree hashes as the locking primitive
  instead of NAR hashes. Predates NixOS#51 and is independent of it
  (different function, different scope). Now has a tracking
  number rather than living only in source. Filed in
  19-eval-core-fetcher-lookup-json.md.

STATUS.md: catalog count bumped to 238 + 44; added a sentence
to the "Catalog split into 25 sections" recently-completed
entry explaining the NixOS#234-NixOS#238 origin.

FOLLOWUPS.md: new "Batch G follow-ups (adversarial-audit
second pass)" subsection with all five strikethroughs naming
the filed candidates and their homes.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 25, 2026
…store type

The two legacy --add-root call sites that share GcRootNamer state had a
silent asymmetry. nix-instantiate ran "if empty: warn; else: bump
counter then dynamic_pointer_cast<LocalFSStore>; if cast: addPermRoot"
— which warned regardless of store type but wasted a counter bump when
the cast failed. nix-store ran "if (store2): if empty: warn; else:
addPermRoot" — which silently did nothing on a non-LocalFSStore even
when the user forgot --add-root. A user running nix-store --realise
against a remote store with no --add-root got no warning; the same
invocation under nix-instantiate did warn.

Hoist the empty-namer check above the store-type cast at all three
sites: warn first (printGCWarning has its own warnOnce flag, so the
"warn regardless of store type" semantics costs nothing at call sites
that don't end up registering a root anyway). The cast then guards
only the addPermRoot call, with the counter bump moved inside the cast
arm so a cast failure doesn't waste counter values.

User-visible change: a non-LocalFSStore user who forgets --add-root
will now see the warning under nix-store --realise (matching the
nix-instantiate behaviour). The warning text is unchanged.

Refs candidate NixOS#235.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 25, 2026
Previous commit changed nix-store --realise to print the
"missing --add-root" warning regardless of store type, matching
nix-instantiate's existing behaviour. This is a user-visible
behaviour change for users running nix-store --realise against
a non-LocalFSStore without --add-root.

Refs candidate NixOS#235.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 25, 2026
The post-Batch-G adversarial-review pass over the next-pick list
flagged five candidates whose bodies overstate the case or
propose churn. Update each body to record the review verdict so
future readers see the actual ship-state, not the original framing.

NixOS#168 — SUPERSEDED by N31. The proposed cache-versions.hh is
  cosmetic colocation; it does not fix the version-in-filename
  antipattern. PRAGMA user_version (NixOS#201) closes the silent-
  corruption window; SqliteCache<Schema, UserVersion> (N13) closes
  the orphan-cache hazard. Recommended action: ship N31 directly
  and let it absorb NixOS#168's surface area.

NixOS#219 — RESOLVED as dead-code defence. Source-verified that the
  post-build hook child is registered with respectTimeouts=false;
  Worker::waitForInput only fires goal->timedOut(...) when the
  flag is true. The TimedOut arm cannot be reached on the post-
  build hook child's goal, so adding it would be defensive coding
  for an unreachable path — not a present-day latent bug.

NixOS#235 — re-scoped. Source-verified that NixOS#91's GcRootNamer landing
  on cleanup-nix-cli already absorbed counter-increment timing
  and absPath-timing divergences. The only residual divergence is
  printGCWarning gating (nix-store gates on store2 != nullptr;
  nix-instantiate runs unconditionally). Tightened body to
  describe the single remaining asymmetry; effort downgraded from
  small to trivial.

NixOS#236 — DECLINED. Both proposed paths are churn: per-format
  subclass family adds 7 new types to remove one inline factory
  list; getCommandsForWithArgs<...> registry is speculative
  public API with one consumer (the same anti-pattern that drove
  the libutil NixOS#163 revert). CmdHash retains its inline factory
  list deliberately; the decision is recorded on NixOS#93's Branch
  line so future readers see it from either entry point.

NixOS#231 — body tightened. Dropped the "sibling getIntArgNoUnit<N>
  template if a second caller appears" footnote — speculative-
  API framing. Ship the conservative form (inline getArg
  substitution at the one site); the helper can be re-filed if
  and when a second caller actually materialises.

No code changes; doc-branch only.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 25, 2026
After the cross-shard cleanup landed, fan out the post-review
punch-list across single-shard commits. Three trivials (NixOS#183,
NixOS#231, NixOS#235) and three smalls (NixOS#226, NixOS#230, NixOS#234) shipped; three
rejected per body-edit verdicts (NixOS#168 superseded, NixOS#219 dead-code
defence, NixOS#236 declined); one deferred (NixOS#225 needs a libutil
helper that would create a third cross-shard violation if
bundled).

STATUS cleanup-branches table updated with the new tip SHAs:
- libstore   80fd74bca (was ec50b5b)
- libutil    190b08372 (was fdb46ab33)
- libfetchers 12a17bb65 (was d1a856c)
- nix-cli    24ebbcc (was 2a34c31)
plus the new candidate references (NixOS#183, NixOS#231, NixOS#235 on nix-cli;
NixOS#226 on libutil; NixOS#230 on libfetchers; NixOS#234 on libstore).

NixOS#235 carries a user-visible behaviour change: nix-store --realise
now warns about missing --add-root regardless of store type
(matching nix-instantiate's existing behaviour). rl-next entry
ships on the same branch.

Final cross-shard audit: zero true violations. The few remaining
multi-directory commits are either consumer call-site adoption
(libflake/libmain → src/nix/) which is the normal "ripple" pattern,
or internal-api-docs/source pairs which are auto-updated when
public surface changes — neither blocks independent landing.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 25, 2026
…de-off + STATUS

Adversarial review of the Batch H code + the cross-shard cleanup
caught one real bug (NixOS#234 thread-safety, fixed on libstore branch
in commit 689effee2) and several documentation gaps. This commit
records the documentation fixes.

Six shipped candidates were missing **Branch:** lines in their
catalog bodies, leaving a reader of the candidate body unable to
find where each shipped:

  NixOS#183 → 18-daemon-protocol-audit.md (libstore)
  NixOS#226 → 12-libutil-libstore-core-extras.md (libutil)
  NixOS#230 → 03-repeated-boilerplate.md (libfetchers)
  NixOS#231 → 11-legacy-cli.md (nix-cli)
  NixOS#234 → 12-libutil-libstore-core-extras.md (libstore)
  NixOS#235 → 11-legacy-cli.md (nix-cli)

Each Branch line now describes what landed and where, with the
specific implementation choices that diverge from the candidate's
original sketch (e.g., NixOS#235's call-site-only fix versus the
candidate's GcRootNamer-coupling proposal; NixOS#234's std::unique_ptr
values for pointer-stability instead of holding the lock through
the signing call).

NixOS#119 and NixOS#221's Branch lines (already correctly pointing at the
libutil branch post-cross-shard cleanup) gained an explicit
trade-off discussion. The libutil header halves of both
candidates currently have zero in-tree consumers (waiting on
queued NixOS#239/NixOS#240 to land after libutil merges upstream).
Structurally similar to the libutil NixOS#163 revert, but
differentiated by: (a) the consumers are filed and tracked, not
hypothetical; (b) the original implementation was bundled and
shipped before the cross-shard cleanup split it; (c) the gap is
bounded by upstream merge ordering. Decision recorded: accept
the trade-off, ship the libutil header now, land NixOS#239/NixOS#240
immediately after libutil merges. Re-evaluate if libutil fails
to merge upstream within the catalog work's expected lifetime.

A minor information-loss regression in NixOS#230 was caught and
fixed: the GitLab `// FIXME: get username somewhere` comment was
attached to the inline `clone()` body in the original
GitLabInputScheme, and got dropped when `clone()` was hoisted to
the base class. Restored as a class-level comment on
GitLabInputScheme so future readers see the GitLab-specific
concern about clone URLs needing a username for some HTTPS-clone
setups. Amended in libfetchers commit 572e8fd (was 12a17bb65).

STATUS.md updated:
- libstore tip moves from 80fd74bca to 689effee2 (NixOS#234 amend)
- libfetchers tip moves from 12a17bb65 to 572e8fd (NixOS#230 amend)
- libstore row NixOS#234 description tightened to mention pointer-
  stability via std::unique_ptr
- libfetchers row NixOS#230 description mentions the FIXME preservation
- New "Post-batch-H adversarial review" recently-completed entry
  summarising the bug fix + doc-gap closures + trade-off note

Other five cleanup branches unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 25, 2026
…3 coverage gaps + NixOS#218 stale inventory

Pass-4 adversarial review caught a BLOCKER and three lower-grade
findings. The BLOCKER (NixOS#185 missing rl-next) was fixed in a
separate commit on cleanup-libstore (09abb81); this commit
records the doc-branch fallout.

STATUS.md cleanup-branches table libstore row: tip moves to
09abb81 (was 6022c29) with a Pass-4 review note. STATUS
Current tip SHAs block updated in lockstep.

New "Post-batch-H Pass-4" recently-completed entry summarising
the BLOCKER fix and three coverage-gap findings recorded but
not actioned this round (any new tests would mean new commits
on already-pushed branches; defer until the next batch lands
alongside).

Catalog body amends:

- NixOS#218 wire-marker inventory (12-libutil-libstore-core-extras.md)
  added a "Pre-implementation note (Pass-4 review)" warning
  that the `worker-protocol.cc`-cited site is pre-NixOS#1+NixOS#3
  template-lift; the marker now lives in
  `common-protocol-impl.hh`. NixOS#218 is queued/unimplemented; the
  note prompts a re-run of the inventory grep before scoping.
- NixOS#222 Branch line gained a "Coverage gap" note: the negative-
  value error path has no functional-test coverage.
- NixOS#235 Branch line gained a "Coverage gap" note: no functional
  test asserts the warning text appears on stderr.

NixOS#80's existing Branch line already self-disclosed "No existing
tests exercised the Windows side"; no edit needed there.

Push-state finding (recorded in STATUS, not actioned): three of
seven origin tips diverge and require force-push when
published — libstore (origin still has dropped b9a750f),
libutil (origin still has pre-rebase da1e0d7), nix-cli
(origin lacks Batch H).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 29, 2026
…store type

The two legacy --add-root call sites that share GcRootNamer state had a
silent asymmetry. nix-instantiate ran "if empty: warn; else: bump
counter then dynamic_pointer_cast<LocalFSStore>; if cast: addPermRoot"
— which warned regardless of store type but wasted a counter bump when
the cast failed. nix-store ran "if (store2): if empty: warn; else:
addPermRoot" — which silently did nothing on a non-LocalFSStore even
when the user forgot --add-root. A user running nix-store --realise
against a remote store with no --add-root got no warning; the same
invocation under nix-instantiate did warn.

Hoist the empty-namer check above the store-type cast at all three
sites: warn first (printGCWarning has its own warnOnce flag, so the
"warn regardless of store type" semantics costs nothing at call sites
that don't end up registering a root anyway). The cast then guards
only the addPermRoot call, with the counter bump moved inside the cast
arm so a cast failure doesn't waste counter values.

User-visible change: a non-LocalFSStore user who forgets --add-root
will now see the warning under nix-store --realise (matching the
nix-instantiate behaviour). The warning text is unchanged.

Refs candidate NixOS#235.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 29, 2026
Previous commit changed nix-store --realise to print the
"missing --add-root" warning regardless of store type, matching
nix-instantiate's existing behaviour. This is a user-visible
behaviour change for users running nix-store --realise against
a non-LocalFSStore without --add-root.

Refs candidate NixOS#235.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Feature request or proposal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants