aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/local-store.hh
AgeCommit message (Collapse)Author
2023-04-14Support `repairPath` on most stores.John Ericson
More progress on issue #5729 The method trivially generalizes to be store-implementation-agnostic, in fact. However, we force it to continue to be unimplemented with `RemoteStore` and `LegacySSHStore` because the implementation we'd get via the generalization is probably not the one users expect. This keeps our hands untied to do it right going forward. For more about the tension between the scheduler logic being store-type-agnostic and remote stores doing their own scheduling, see issues #5025 and #5056.
2023-04-07Finish converting existing comments for internal API docs (#8146)John Ericson
* Finish converting existing comments for internal API docs 99% of this was just reformatting existing comments. Only two exceptions: - Expanded upon `BuildResult::status` compat note - Split up file-level `symbol-table.hh` doc comments to get per-definition docs Also fixed a few whitespace goofs, turning leading tabs to spaces and removing trailing spaces. Picking up from #8133 * Fix two things from comments * Use triple-backtick not indent for `dumpPath` * Convert GNU-style `\`..'` quotes to markdown style in API docs This will render correctly.
2023-04-07Liberate `checkDerivationOutputs` from `LocalStore`John Ericson
Make it instead a method on `Derivation` that can work with any store. We will need this for a CLI command to create a derivation.
2023-04-06Add `Store::isTrustedClient()`matthewcroughan
This function returns true or false depending on whether the Nix client is trusted or not. Mostly relevant when speaking to a remote store with a daemon. We include this information in `nix ping store` and `nix doctor` Co-Authored-By: John Ericson <John.Ericson@Obsidian.Systems>
2023-04-02Move `querySubstitutablePathInfos` from `LocalStore` to `Store`John Ericson
The code is not local-store-specific, so we should share it with all stores. More uniform behavior is better, and a less store-specific functionality is more maintainable. This fixes a FIXME added in f73d911628 by @edolstra himself.
2023-03-31Ensure all headers have `#pragma once` and are in API docsJohn Ericson
`///@file` makes them show up in the internal API dos. A tiny few were missing `#pragma once`.
2023-03-23Register LocalStore to ensure it's included in the manualEelco Dolstra
2023-03-22Improve store setting descriptions / Markdown formattingEelco Dolstra
2023-03-21Support per-store Markdown documentationEelco Dolstra
2023-01-17Move the default profiles to the user’s homeThéophane Hufschmitt
Rather than using `/nix/var/nix/{profiles,gcroots}/per-user/`, put the user profiles and gcroots under `$XDG_DATA_DIR/nix/{profiles,gcroots}`. This means that the daemon no longer needs to manage these paths itself (they are fully handled client-side). In particular, it doesn’t have to `chown` them anymore (removing one need for root). This does change the layout of the gc-roots created by nix-env, and is likely to break some stuff, so I’m not sure how to properly handle that.
2023-01-03Fix deadlock between auto-GC and addTempRoot()Eelco Dolstra
Previously addTempRoot() acquired the LocalStore state lock and waited for the garbage collector to reply. If the garbage collector is in the same process (as it the case with auto-GC), this would deadlock as soon as the garbage collector thread needs the LocalStore state lock. So now addTempRoot() uses separate Syncs for the state that it needs. As long at the auto-GC thread doesn't call addTempRoot() (which it shouldn't), it shouldn't deadlock. Fixes #3224.
2023-01-03Move creation of the temp roots file into its own functionEelco Dolstra
This also moves the file handle into its own Sync object so we're not holding the _state while acquiring the file lock. There was no real deadlock risk here since locking a newly created file cannot block, but it's still a bit nicer.
2022-11-03Merge remote-tracking branch 'origin/master' into auto-uid-allocationEelco Dolstra
2022-09-06Keep created temp dirs inside store, but protect from GCAndrew Brooks
Implements the approach suggested by feedback on PR #6994, where tempdir paths are created in the store (now with an exclusive lock). As part of this work, the currently-broken and unused `createTempDirInStore` function is updated to create an exclusive lock on the temp directory in the store. The GC now makes a non-blocking attempt to lock any store directories that "look like" the temp directories created by this function, and if it can't acquire one, ignores the directory.
2022-03-03Factor out a `GcStore` interfaceJohn Ericson
Starts progress on #5729. The idea is that we should not have these default methods throwing "unimplemented". This is a small step in that direction. I kept `addTempRoot` because it is a no-op, rather than failure. Also, as a practical matter, it is called all over the place, while doing other tasks, so the downcasting would be annoying. Maybe in the future I could move the "real" `addTempRoot` to `GcStore`, and the existing usecases use a `tryAddTempRoot` wrapper to downcast or do nothing, but I wasn't sure whether that was a good idea so with a bias to less churn I didn't do it yet.
2022-02-28Merge remote-tracking branch 'upstream/master' into auto-uid-allocationJohn Ericson
2022-02-25Remove std::string alias (for real this time)Eelco Dolstra
Also use std::string_view in a few more places.
2022-02-21Remove std::set aliasEelco Dolstra
2022-02-16addToStoreFromDump(): Take std::string_viewEelco Dolstra
2022-01-25nix store ping: Report Nix daemon versionEelco Dolstra
Fixes #5952.
2022-01-18Add command 'nix store copy-log'Eelco Dolstra
Fixes #5222.
2022-01-11Prefer RepairFlag over bool when applicableGuillaume Maudoux
2022-01-11Make --repair-path also repair corrupt optimised linksGuillaume Maudoux
There already existed a smoke test for the link content length, but it appears that there exists some corruptions pernicious enough to replace the file content with zeros, and keeping the same length. --repair-path now goes as far as checking the content of the link, making it true to its name and actually repairing the path for such coruption cases.
2021-11-16Merge pull request #5472 from NixOS/async-realisation-substitutionEelco Dolstra
async realisation substitution
2021-11-09Merge pull request #5494 from tweag/balsoft/allow-references-in-addPathEelco Dolstra
Allow references in addPath
2021-11-09addToStore, addToStoreFromDump: refactor: pass refs by const referenceAlexander Bantyev
Co-Authored-By: Eelco Dolstra <edolstra@gmail.com>
2021-11-03Expose an async interface for `queryRealisation`regnat
Doesn’t change much so far because everything is still using it synchronously, but should allow the binary cache to fetch stuff in parallel
2021-10-23addToStore, addToStoreFromDump: add references argumentAlexander Bantyev
Allow to pass a set of references to be added as info to the added paths.
2021-10-14Remove GCStateEelco Dolstra
2021-10-14Move deleteFromStore()Eelco Dolstra
2021-10-14Make the canReachRoots() traversal non-recursiveEelco Dolstra
2021-10-13Fix GC when there are cycles in the referrers graphEelco Dolstra
(where "referrers" includes the reverse of derivation outputs and derivers). Now we do a full traversal to look if we can reach any root. If not, all paths reached can be deleted.
2021-10-13SimplifyEelco Dolstra
2021-10-13Fix auto-gcEelco Dolstra
2021-10-13Non-blocking garbage collectorEelco Dolstra
The garbage collector no longer blocks other processes from adding/building store paths or adding GC roots. To prevent the collector from deleting store paths just added by another process, processes need to connect to the garbage collector via a Unix domain socket to register new temporary roots.
2021-10-13Remove syncWithGC()Eelco Dolstra
2021-10-13Remove trash directoryEelco Dolstra
2021-09-15Merge remote-tracking branch 'upstream/master' into auto-uid-allocationMatthew Kenigsberg
2021-06-23Properly fail when trying to register an incoherent realisationregnat
2021-06-18UDSRemoteStore: Support the 'root' store parameterEelco Dolstra
Useful when we're using a daemon with a chroot store, e.g. $ NIX_DAEMON_SOCKET_PATH=/tmp/chroot/nix/var/nix/daemon-socket/socket nix-daemon --store /tmp/chroot Then the client can now connect with $ nix build --store unix:///tmp/chroot/nix/var/nix/daemon-socket/socket?root=/tmp/chroot nixpkgs#hello
2021-06-01Check the CA hash when importing stuff in the local storeregnat
When adding a path to the local store (via `LocalStore::addToStore`), ensure that the `ca` field of the provided `ValidPathInfo` does indeed correspond to the content of the path. Otherwise any untrusted user (or any binary cache) can add arbitrary content-addressed paths to the store (as content-addressed paths don’t need a signature).
2021-04-27Merge remote-tracking branch 'upstream/master' into auto-uid-allocationJohn Ericson
2021-03-15Check the signatures when copying store paths aroundregnat
Broken atm
2021-03-15pathInfoIsTrusted -> pathInfoIsUntrustedregnat
I guess the rationale behind the old name wath that `pathInfoIsTrusted(info)` returns `true` iff we would need to `blindly` trust the path (because it has no valid signature and `requireSigs` is set), but I find it to be a really confusing footgun because it's quite natural to give it the opposite meaning.
2021-03-15Add some logic for signing realisationsregnat
Not exposed anywhere, but built realisations are now signed (and this should be forwarded when copy-ing them around)
2021-03-01SubstitutionGoal -> PathSubstitutionGoalregnat
To prepare for the upcoming DrvOutputSubstitutionGoal
2021-02-26Split {,local-}derivation-goal.{cc,hh}John Ericson
This separates the scheduling logic (including simple hook pathway) from the local-store needing code. This should be the final split for now. I'm reasonably happy with how it's turning out, even before I'm done moving code into `local-derivation-goal`. Benefits: 1. This will help "witness" that the hook case is indeed a lot simpler, and also compensate for the increased complexity that comes from content-addressed derivation outputs. 2. It also moves us ever so slightly towards a world where we could use off-the-shelf storage or sandboxing, since `local-derivation-goal` would be gutted in those cases, but `derivation-goal` should remain nearly the same. The new `#if 0` in the new files will be deleted in the following commit. I keep it here so if it turns out more stuff can be moved over, it's easy to do so in a way that preserves ordering --- and thus prevents conflicts. N.B. ```sh git diff HEAD^^ --color-moved --find-copies-harder --patience --stat ``` makes nicer output.
2021-02-19Register the realisations for unresolved drvsregnat
Once a build is done, get back to the original derivation, and register all the newly built outputs for this derivation. This allows Nix to work properly with derivations that don't have all their build inputs available − thus allowing garbage collection and (once it's implemented) binary substitution
2021-01-15Make public keys and `requireSigs` local-store specific againJohn Ericson
Thanks @regnat and @edolstra for catching this and comming up with the solution. They way I had generalized those is wrong, because local settings for non-local stores is confusing default. And due to the nature of C++ inheritance, fixing the defaults is more annoying than it should be. Additionally, I thought we might just drop the check in the substitution logic since `Store::addToStore` is now streaming, but @regnat rightfully pointed out that as it downloads dependencies first, that would still be too late, and also waste effort on possibly unneeded/unwanted dependencies. The simple and correct thing to do is just make a store method for the boolean logic, keeping all the setting and key stuff the way it was before. That new method is both used by `LocalStore::addToStore` and the substitution goal check. Perhaps we might eventually make it fancier, e.g. sending the ValidPathInfo to remote stores for them to validate, but this is good enough for now.
2021-01-15Merge remote-tracking branch 'upstream/master' into non-local-store-buildJohn Ericson