1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-13 14:02:42 +01:00
Nix, the purely functional package manager
Find a file
Bernardo Meurer Costa 40beb50e8f
refactor(libstore): integrate DependencyGraph with store path scanning
Adds buildStorePathGraphFromScan() to bridge the generic DependencyGraph
infrastructure with Nix's store path reference scanning. This enables
building annotated dependency graphs that track which files create which
dependencies.

## New API: buildStorePathGraphFromScan()

**Purpose**: Convert file-level scan results into a StorePath-level graph

**How it works**:
1. Calls scanForReferencesDeep() to find which files contain references
2. For each file that references another store path:
   - Adds edge: rootStorePath → referencedStorePath
   - Attaches FileListEdgeProperty with the file path
3. Returns DependencyGraph<StorePath, FileListEdgeProperty>

**Key benefit**: The graph carries file-level provenance. When you see
an edge A→B, you can query which files in A reference B. Essential for:
- why-depends output showing exact file locations
- Future: detailed cycle error messages

## API Changes

**scanForReferencesDeep() callback signature**:
```cpp
// Before: std::function<void(FileRefScanResult)>
// After:  std::function<void(const FileRefScanResult &)>
```

Pass by const-ref to avoid copying large result structures.

## Usage Example

```cpp
auto graph = buildStorePathGraphFromScan(
    *accessor,
    CanonPath("/nix/store/abc-foo"),
    storePathAbc,
    candidateRefs
);

// Query file annotations
auto edgeProp = graph.getEdgeProperty(storePathAbc, storePathDef);
// edgeProp->files contains files that created this edge
```

## Implementation Details

- Uses DependencyGraph's edge properties feature
- FileListEdgeProperty defined in dependency-graph.hh
- Merges duplicate edges (multiple files → same path)
- Debug logging for discovered edges
- Zero overhead if file-level detail not needed
2025-10-28 05:47:45 +00:00
.github ci: cancel previous workflow runs on PR updates 2025-10-27 20:56:56 +00:00
ci/gha Add JSON Schema infrastructure, use for Derivation 2025-10-16 17:24:18 -04:00
contrib function-trace: always show the trace 2019-09-18 23:23:21 +02:00
doc/manual nlohmann::json instance and JSON Schema for ContentAddress 2025-10-27 14:47:50 -04:00
maintainers maintainers: Remove mergify note from release-process.md 2025-10-08 00:51:50 +03:00
misc shellcheck fix: completion files 2025-09-26 08:41:30 -07:00
nix-meson-build-support Disable detect_odr_violation for ASan 2025-10-12 19:16:07 +03:00
packaging Add JSON Schema infrastructure, use for Derivation 2025-10-16 17:24:18 -04:00
scripts Merge branch 'master' into fzakaria/shellcheck-systemd-multi-user 2025-09-25 07:40:27 +02:00
src refactor(libstore): integrate DependencyGraph with store path scanning 2025-10-28 05:47:45 +00:00
tests feat(libstore): support S3 object versioning via versionId parameter 2025-10-25 07:57:58 +00:00
.clang-format Update clang-format with fixing namespace coments, and separate definition blocks 2025-07-18 12:46:51 -04:00
.clang-tidy Add .clang-tidy 2024-02-01 01:01:39 +01:00
.dir-locals.el .dir-locals.el: Set c-block-comment-prefix 2020-07-10 11:21:06 +02:00
.editorconfig No global eval settings in libnixexpr 2024-06-24 12:15:16 -04:00
.git-blame-ignore-revs git-blame-ignore-revs: Add nixfmt 1.0.0 reformat 2025-08-18 20:30:54 +03:00
.gitignore Overriding gtest with gmock 2025-05-31 07:41:27 -07:00
.shellcheckrc housekeeping: shellcheck for tests/functional/ca/build-cache.sh 2024-06-12 17:41:16 -04:00
.version Bump version 2025-10-07 17:15:28 +02:00
CITATION.cff chore: PhD thesis as reference in CITATION.cff 2024-05-18 20:05:22 +02:00
CONTRIBUTING.md Update developer facing links to nix.dev 2025-07-25 10:59:44 +02:00
COPYING COPYING: update to latest lgpl-2.1.txt (fixes #13758) 2025-09-18 00:45:01 +08:00
default.nix Format .nix files 2025-01-24 17:04:02 +01:00
docker.nix Merge pull request #13524 from gmarti/fix_cacertificate 2025-08-28 23:28:53 +03:00
flake.lock flake: Update nixpkgs 2025-08-27 02:23:05 +03:00
flake.nix flake.nix: Add nix run .#open-manual 2025-10-22 00:42:18 +02:00
HACKING.md Rename doc/manual{src -> source} 2024-10-14 11:21:24 -04:00
meson.build Add JSON Schema infrastructure, use for Derivation 2025-10-16 17:24:18 -04:00
meson.format flake: Add meson formatter 2025-06-11 22:08:03 +00:00
meson.options add derivation parser benchmark 2025-07-29 16:51:55 +02:00
README.md fix(docs): update Matrix channel links 2025-05-04 12:17:48 +02:00
shell.nix Remove url literals 2022-01-24 13:28:21 +01:00

Nix

Open Collective supporters CI

Nix is a powerful package manager for Linux and other Unix systems that makes package management reliable and reproducible. Please refer to the Nix manual for more details.

Installation and first steps

Visit nix.dev for installation instructions and beginner tutorials.

Full reference documentation can be found in the Nix manual.

Building and developing

Follow instructions in the Nix reference manual to set up a development environment and build Nix from source.

Contributing

Check the contributing guide if you want to get involved with developing Nix.

Additional resources

Nix was created by Eelco Dolstra and developed as the subject of his PhD thesis The Purely Functional Software Deployment Model, published 2006. Today, a world-wide developer community contributes to Nix and the ecosystem that has grown around it.

License

Nix is released under the LGPL v2.1.