refactor: drop nixpkgs lib dependency (pure builtins tree reader)#36
Open
sini wants to merge 1 commit into
Open
refactor: drop nixpkgs lib dependency (pure builtins tree reader)#36sini wants to merge 1 commit into
sini wants to merge 1 commit into
Conversation
The tree reader used seven nixpkgs lib helpers. Restructure the two
`lib.pipe` chains into plain let-bindings (the `makeRelative` function-list
fold collapses into a direct `builtins.foldl'` over the roots) and vendor the
genuine primitives inline: `flatten`, `hasPrefix`, `removePrefix`, `hasSuffix`,
`hasInfix`, and `listFilesRecursive`. Each carries a provenance comment naming
its nixpkgs origin; all are behavior-identical (verified against nixpkgs over
sampled and adversarial inputs, incl. regex-meta chars and newlines).
The whole `withLib`/lib-threading machinery existed only to obtain those
helpers, so it dissolves: no more `lib == null` throw, no `leafs = lib:`
threading, no `module = { lib, ... }:` delay trick. Consequence: `.leafs`,
`.files` and `.pipeTo` now work everywhere with zero setup, including outside
module evaluation.
`withLib` is retained as a silent no-op so existing `it.withLib pkgs.lib`
callers keep working, and is removed from the docs. The library keeps its
zero-dependency flake (no new inputs).
34/34 tests pass; treefmt clean.
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.
Summary
Removes the
nixpkgslibdependency from the tree reader. The library core is now purebuiltins—import-treestays a zero-dependency flake (no new inputs).The seven
libhelpers previously used were handled two ways:lib.pipe— restructured away, not vendored. Both pipe chains became plainlet-bindings. ThemakeRelativechain (which built a list ofisFileRelativepartial applications and fold-applied over it) collapses into a directbuiltins.foldl' (acc: root: isFileRelative root acc)over the root dirs — a genuine simplification.flatten,hasPrefix,removePrefix,hasSuffix,hasInfix,listFilesRecursive.hasInfixis a literal substring scan (no regex-escaping surface); behavior-identical for its sole internal use.Every vendored util was cross-checked against
nixpkgs.libover sampled and adversarial inputs (regex-meta chars, newlines, empty/oversized infixes) — no divergences.listFilesRecursiveoutput is byte-identical (order + set).Behavior change
The
withLib/ lib-threading machinery existed only to obtain those helpers, so it dissolves (nolib == nullthrow, noleafs = lib:threading, nomodule = { lib, ... }:delay trick). As a result,.leafs,.filesand.pipeTonow work everywhere with zero setup — nowithLibcall needed, including outside module evaluation.withLibis retained as a silent no-op so existingit.withLib pkgs.libcallers keep working; it is removed from the docs. The emittedmodulestays a lambda, so the tree read remains deferred to module-eval (constructingit ./dirdoes not walk the filesystem).Tests & docs
34/34tests pass;treefmtclean;just cigreen.withLiband thatwithLibremains a working no-op.withLibreferences removed from docs; combinator-guide examples reworked to lib-free demo operations.