aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/local-store.hh
AgeCommit message (Collapse)Author
2021-01-05Fix deadlock in LocalStore::addSignatures()Eelco Dolstra
Fixes #4367.
2020-12-20Overhaul store subclassingJohn Ericson
We embrace virtual the rest of the way, and get rid of the `assert(false)` 0-param constructors. We also list config base classes first, so the constructor order is always: 1. all the configs 2. all the stores Each in the same order
2020-12-17Fix the detection of already built drv outputsregnat
PRs #4370 and #4348 had a bad interaction in that the second broke the fist one in a not trivial way. The issue was that since #4348 the logic for detecting whether a derivation output is already built requires some logic that was specific to the `LocalStore`. It happens though that most of this logic could be upstreamed to any `Store`, which is what this commit does.
2020-12-11Rework the db schema for derivation outputsregnat
Add a new table for tracking the derivation output mappings. We used to hijack the `DerivationOutputs` table for that, but (despite its name), it isn't a really good fit: - Its entries depend on the drv being a valid path, making it play badly with garbage collection and preventing us to copy a drv output without copying the whole drv closure too; - It dosen't guaranty that the output path exists; By using a different table, we can experiment with a different schema better suited for tracking the output mappings of CA derivations. (incidentally, this also fixes #4138)
2020-12-11Store metadata about drv outputs realisationsregnat
For each known realisation, store: - its output - its output path This comes with a set of needed changes: - New `realisations` module declaring the types needed for describing these mappings - New `Store::registerDrvOutput` method registering all the needed informations about a derivation output (also replaces `LocalStore::linkDeriverToPath`) - new `Store::queryRealisation` method to retrieve the informations for a derivations This introcudes some redundancy on the remote-store side between `wopQueryDerivationOutputMap` and `wopQueryRealisation`. However we might need to keep both (regardless of backwards compat) because we sometimes need to get some infos for all the outputs of a derivation (where `wopQueryDerivationOutputMap` is handy), but all the stores can't implement it − because listing all the outputs of a derivation isn't really possible for binary caches where the server doesn't allow to list a directory.
2020-12-08Hide the sqlite statements declarations for the local storeregnat
These have no need to be in the public interface and it causes spurious rebuilds each time one wants to add or remove a new statement.
2020-12-01shut up clang warningsregnat
- Fix some class/struct discrepancies - Explicit the overloading of `run` in the `Cmd*` classes - Ignore a warning in the generated lexer
2020-11-03LocalStore: Get rid of recursive_mutexEelco Dolstra
2020-11-03Add FIXMEEelco Dolstra
2020-10-09Split out `local-fs-store.hh`John Ericson
This matches the already-existing `local-fs-store.cc`.
2020-09-16Add a name to the storesregnat
So that it can be printed by `nix describe-stores`
2020-09-16Correctly call all the parent contructors of the storesregnat
Using virtual inheritance means that only the default constructors of the parent classes will be called, which isn't what we want
2020-09-16Separate store configs from the implemsregnat
Rework the `Store` hierarchy so that there's now one hierarchy for the store configs and one for the implementations (where each implementation extends the corresponding config). So a class hierarchy like ``` StoreConfig-------->Store | | v v SubStoreConfig----->SubStore | | v v SubSubStoreConfig-->SubSubStore ``` (with virtual inheritance to prevent DDD). The advantage of this architecture is that we can now introspect the configuration of a store without having to instantiate the store itself
2020-09-04Fix some of the issues raised by @edolstraJohn Ericson
- More and better comments - The easier renames
2020-08-28Merge remote-tracking branch 'upstream/master' into single-ca-drv-buildJohn Ericson
2020-08-27Merge pull request #3434 from Ericson2314/derivation-header-include-orderEelco Dolstra
Revise division of labor in deserialization of derivations
2020-08-20Rename drv output querying functions, like masterJohn Ericson
- `queryDerivationOutputMapAssumeTotal` -> `queryPartialDerivationOutputMap` - `queryDerivationOutputMapAssumeTotal` -> `queryDerivationOutputMap
2020-08-20Rename drv output querying functionsJohn Ericson
- `queryDerivationOutputMapAssumeTotal` -> `queryPartialDerivationOutputMap` - `queryDerivationOutputMapAssumeTotal` -> `queryDerivationOutputMap`
2020-08-18Merge remote-tracking branch 'upstream/master' into ↵John Ericson
derivation-header-include-order
2020-08-07Squashed get CA derivations buildingJohn Ericson
2020-08-04Merge remote-tracking branch 'upstream/master' into ↵John Ericson
drv-outputs-map-allow-missing
2020-08-03`addToStore` in terms of `addToStoreFromDump` is not local-store-specificJohn Ericson
2020-08-01Merge remote-tracking branch 'upstream/master' into ↵John Ericson
derivation-header-include-order
2020-07-31Merge branch 'master' of github.com:NixOS/nix into drv-outputs-map-allow-missingCarlo Nucera
2020-07-30Merge remote-tracking branch 'origin/master' into substitute-other-storedirMatthew Bauer
2020-07-30unsigned long long -> uint64_tEelco Dolstra
2020-07-24`queryDerivationOutputMap` no longer assumes all outputs have a mappingJohn Ericson
This assumption is broken by CA derivations. Making a PR now to do the breaking daemon change as soon as possible (if it is already too late, we can bump protocol intead).
2020-07-15Get rid of `LocalStore::addToStoreCommon`John Ericson
I got it to just become `LocalStore::addToStoreFromDump`, cleanly taking a store and then doing nothing too fancy with it. `LocalStore::addToStore(...Path...)` is now just a simple wrapper with a bare-bones sinkToSource of the right dump command.
2020-07-15Merge branch 'master' of github.com:NixOS/nix into ↵Carlo Nucera
derivation-header-include-order
2020-07-14LocalStore::addToStoreFromDump copy in chunksJohn Ericson
Rather than copying byte-by-byte, we let the coroutine know how much data we would like it to send back to us.
2020-07-14Dedup `LocalStore::addToStore*`John Ericson
The downsides is that the coroutine has byte-by-byte loop transfer. Will fix that next.
2020-07-14Crudely make `addToStoreFromDump` take `Source` not stringJohn Ericson
I just as little beyond the type as possible, so the implementation changes this enables can be reviewed separately.
2020-07-13Remove 'accessor' from addToStore()Eelco Dolstra
This is only used by hydra-queue-runner and it's better to implement it there.
2020-07-05Merge remote-tracking branch 'upstream/master' into ↵John Ericson
derivation-header-include-order
2020-07-02Merge remote-tracking branch 'origin/master' into substitute-other-storedirMatthew Bauer
2020-06-24Add a way to get all the outputs of a derivation with their labelregnat
Generalize `queryDerivationOutputNames` and `queryDerivationOutputs` by adding a `queryDerivationOutputMap` that returns the map `outputName=>outputPath` (not that this is not equivalent to merging the results of `queryDerivationOutputs` and `queryDerivationOutputNames` as sets don't preserve the order, so we would end up with an incorrect mapping). squash! Add a way to get all the outputs of a derivation with their label Rename StorePathMap to OutputPathMap
2020-06-17Add StorePathCAMap for querySubstitutablePathInfosMatthew Bauer
I’m not 100% sure this is wanted since it kind of makes everything have to know about ca even if they don’t really want to. But it also make things easier in dealing with looking up ca.
2020-06-17Merge remote-tracking branch 'origin/master' into substitute-other-storedirMatthew Bauer
2020-06-17Don't need abstract `struct Derivation` in local-storeJohn Ericson
2020-06-12Allow substituting from different storeDirMatthew Bauer
Substituters can substitute from one store dir to another with a little bit of help. The store api just needs to have a CA so it can recompute the store path based on the new store dir. We can only do this for fixed output derivations with no references, though.
2020-06-12Remove Store::queryDerivationOutputNames()Eelco Dolstra
This function was used in only one place, where it could easily be replaced by readDerivation() since it's not performance-critical. (This function appears to have been modelled after queryDerivationOutputs(), which exists only to make the garbage collector faster.)
2020-03-29Replace some `bool recursive` with a new `FileIngestionMethod` enumJohn Ericson
2019-12-10Make the Store API more type-safeEelco Dolstra
Most functions now take a StorePath argument rather than a Path (which is just an alias for std::string). The StorePath constructor ensures that the path is syntactically correct (i.e. it looks like <store-dir>/<base32-hash>-<name>). Similarly, functions like buildPaths() now take a StorePathWithOutputs, rather than abusing Path by adding a '!<outputs>' suffix. Note that the StorePath type is implemented in Rust. This involves some hackery to allow Rust values to be used directly in C++, via a helper type whose destructor calls the Rust type's drop() function. The main issue is the dynamic nature of C++ move semantics: after we have moved a Rust value, we should not call the drop function on the original value. So when we move a value, we set the original value to bitwise zero, and the destructor only calls drop() if the value is not bitwise zero. This should be sufficient for most types. Also lots of minor cleanups to the C++ API to make it more modern (e.g. using std::optional and std::string_view in some places).
2019-11-22getEnv(): Return std::optionalEelco Dolstra
This allows distinguishing between an empty value and no value.
2019-10-29queryPathInfoUncached(): Return const ValidPathInfoEelco Dolstra
2019-10-29Move addToStoreFromDump to StoreEelco Dolstra
2019-10-09Remove world-writability from per-user directoriesEelco Dolstra
'nix-daemon' now creates subdirectories for users when they first connect. Fixes #509 (CVE-2019-17365). Should also fix #3127.
2019-09-03Add some noexceptsEelco Dolstra
This is to assert that callback functions should never throw (since the context in which they're called may not be able to handle the exception).
2019-08-02Use BSD instead of POSIX file locksEelco Dolstra
POSIX file locks are essentially incompatible with multithreading. BSD locks have much saner semantics. We need this now that there can be multiple concurrent LocalStore::buildPaths() invocations.
2019-03-14findRoots(): Add 'censor' parameterEelco Dolstra
This is less brittle than filtering paths after the fact in nix-daemon.