aboutsummaryrefslogtreecommitdiff
path: root/doc/manual/src
diff options
context:
space:
mode:
authorValentin Gagarin <valentin.gagarin@tweag.io>2022-04-29 01:15:33 +0200
committerValentin Gagarin <valentin.gagarin@tweag.io>2022-08-04 12:37:47 +0200
commite90586c0a40cf59df9d39407dcc49d5944a8b853 (patch)
tree86d4fb9771112628fe9965328b5626868860de83 /doc/manual/src
parent07d490fd895b09144684dd8b389ef02f0f1256c4 (diff)
add motivation for references
Diffstat (limited to 'doc/manual/src')
-rw-r--r--doc/manual/src/architecture/store/objects.md15
1 files changed, 13 insertions, 2 deletions
diff --git a/doc/manual/src/architecture/store/objects.md b/doc/manual/src/architecture/store/objects.md
index 7f341c87c..30683d22d 100644
--- a/doc/manual/src/architecture/store/objects.md
+++ b/doc/manual/src/architecture/store/objects.md
@@ -37,9 +37,20 @@ Symlinks pointing outside of their own root, or to a store object without a matc
## Reference {#reference}
-A store object can refer to other store objects or itself.
+A store object can reference other store objects.
-Nix collects these references by scanning file contents for [store paths](./paths.md) when a new store object is created.
+Nix stores have the *closure property*: for each store object in the store, all the store objects it references must also be in the store.
+
+Building, copying and deleting store objects must be done in a way that obeys this property:
+
+- We can only safely delete unreferenced objects.
+
+- When copying, to maintain correctness, either the result must be "revealed" atomically to the destination store, or objects must be copied in reference-dependency order.
+
+- Newly built store objects must only refer to store objects in the closure of the build inputs.
+ This ensures the purity of the build.
+
+### Reference scanning
While references could be arbitrary paths, Nix requires them to be store paths to ensure correctness.
Anything outside a given store is not under control of Nix, and therefore cannot be guaranteed to be present when needed.