aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/derivations.hh
AgeCommit message (Collapse)Author
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-07Include the name in the JSON for derivationsJohn Ericson
This is non-breaking change in the to-JSON direction. This *is* a breaking change in the from-JSON direction, but we don't care, as that is brand new in this PR. `nix show-derivation --help` currently has the sole public documentation of this format, it is updated accordingly.
2023-04-07Create `Derivation::fromJSON`John Ericson
And test, of course
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-29Convert a bunch of comments in headers to Doxygen documentationJohn Ericson
The internal API docs now contain more useful information. Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>
2023-02-19Move `Derivation` toJSON logic to libnixstoreJohn Ericson
2023-01-23Better-scope `Store` forward declarationsJohn Ericson
2023-01-11Split `OutputsSpec` and `ExtendedOutputsSpec`, use the former moreJohn Ericson
`DerivedPath::Built` and `DerivationGoal` were previously using a regular set with the convention that the empty set means all outputs. But it is easy to forget about this rule when processing those sets. Using `OutputSpec` forces us to get it right.
2022-12-07Trivial changes from the lazy-trees branchEelco Dolstra
2022-03-31Rename 'pure' -> 'sandboxed' for consistencyEelco Dolstra
2022-03-31needsNetworkAccess() -> isSandboxed()Eelco Dolstra
2022-03-31Document isPure()Eelco Dolstra
2022-03-31Add support for impure derivationsEelco Dolstra
Impure derivations are derivations that can produce a different result every time they're built. Example: stdenv.mkDerivation { name = "impure"; __impure = true; # marks this derivation as impure outputHashAlgo = "sha256"; outputHashMode = "recursive"; buildCommand = "date > $out"; }; Some important characteristics: * This requires the 'impure-derivations' experimental feature. * Impure derivations are not "cached". Thus, running "nix-build" on the example above multiple times will cause a rebuild every time. * They are implemented similar to CA derivations, i.e. the output is moved to a content-addressed path in the store. The difference is that we don't register a realisation in the Nix database. * Pure derivations are not allowed to depend on impure derivations. In the future fixed-output derivations will be allowed to depend on impure derivations, thus forming an "impurity barrier" in the dependency graph. * When sandboxing is enabled, impure derivations can access the network in the same way as fixed-output derivations. In relaxed sandboxing mode, they can access the local filesystem.
2022-03-29Simplify the handling of the hash moduloThéophane Hufschmitt
Rather than having four different but very similar types of hashes, make only one, with a tag indicating whether it corresponds to a regular of deferred derivation. This implies a slight logical change: The original Nix+multiple-outputs model assumed only one hash-modulo per derivation. Adding multiple-outputs CA derivations changed this as these have one hash-modulo per output. This change is now treating each derivation as having one hash modulo per output. This obviously means that we internally loose the guaranty that all the outputs of input-addressed derivations have the same hash modulo. But it turns out that it doesn’t matter because there’s nothing in the code taking advantage of that fact (and it probably shouldn’t anyways). The upside is that it is now much easier to work with these hashes, and we can get rid of a lot of useless `std::visit{ overloaded`. Co-authored-by: John Ericson <John.Ericson@Obsidian.Systems>
2022-03-18Generalize `DerivationType` in preparation for impure derivationsJohn Ericson
2022-03-17Clean up `DerivationOutput`, and headersJohn Ericson
1. `DerivationOutput` now as the `std::variant` as a base class. And the variants are given hierarchical names under `DerivationOutput`. In 8e0d0689be797f9e42f9b43b06f50c1af7f20b4a @matthewbauer and I didn't know a better idiom, and so we made it a field. But this sort of "newtype" is anoying for literals downstream. Since then we leaned the base class, inherit the constructors trick, e.g. used in `DerivedPath`. Switching to use that makes this more ergonomic, and consistent. 2. `store-api.hh` and `derivations.hh` are now independent. In bcde5456cc3295061a0726881c3e441444dd6680 I swapped the dependency, but I now know it is better to just keep on using incomplete types as much as possible for faster compilation and good separation of concerns.
2022-03-11Reduce variants for derivation hash moduloJohn Ericson
This changes was taken from dynamic derivation (#4628). It` somewhat undoes the refactors I first did for floating CA derivations, as the benefit of hindsight + requirements of dynamic derivations made me reconsider some things. They aren't to consequential, but I figured they might be good to land first, before the more profound changes @thufschmitt has in the works.
2022-02-25Remove std::string alias (for real this time)Eelco Dolstra
Also use std::string_view in a few more places.
2022-01-27return string_views from forceString*pennae
once a string has been forced we already have dynamic storage allocated for it, so we can easily reuse that storage instead of copying.
2021-09-10Remove tabsEelco Dolstra
2021-03-17Remove unimplemented hashAlgoOptRobert Hensing
It was in the header but never implemented.
2021-02-26Simplify the case where the drv is a purely input-addressed oneregnat
2021-02-19Remove the drv resolution caching mechanismregnat
It isn't needed anymore now that don't need to eagerly resolve everything like we used to do. So we can safely get rid of it
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-11Use the hash modulo in the derivation outputsregnat
Rather than storing the derivation outputs as `drvPath!outputName` internally, store them as `drvHashModulo!outputName` (or `outputHash!outputName` for fixed-output derivations). This makes the storage slightly more opaque, but enables an earlier cutoff in cases where a fixed-output dependency changes (but keeps the same output hash) − same as what we already do for input-addressed derivations.
2020-11-19Make drv hash modulo memo table thread-safeJohn Ericson
Let's get one step closer to the daemon not needing to fork.
2020-10-27Allow non-CA derivations to depend on CA derivationsregnat
2020-10-09Remove stray DerivationOutputsAndPaths typeEelco Dolstra
2020-09-28Clarify comment a bitJohn Ericson
2020-09-16Ensure resolved CA derivations are writtenJohn Ericson
so we can link outputs to deriver and thus properly cache.
2020-09-16Merge remote-tracking branch 'upstream/master' into ca-floating-upstreamJohn Ericson
2020-09-15Rename `Derivation::pathOpt` to `Derivation::path`John Ericson
We no longer need the `*Opt` to disambiguate.
2020-09-04Fix querying outputs for CA derivations some moreJohn Ericson
If we resolve using the known path of a derivation whose output we didn't have, we previously blew up. Now we just fail gracefully, returning the map of all outputs unknown.
2020-09-04Merge remote-tracking branch 'obsidian/single-ca-drv-build' into ↵John Ericson
ca-floating-upstream
2020-09-04Fix some of the issues raised by @edolstraJohn Ericson
- More and better comments - The easier renames
2020-09-04Fix floating CA testsJohn Ericson
We will sometimes try to query the outputs of derivations we can't resolve. That's fine; it just means we don't know what those outputs are yet.
2020-08-28Merge remote-tracking branch 'obsidian/single-ca-drv-build' into ↵John Ericson
ca-floating-upstream
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-24CA derivations that depend on other CA derivationsJohn Ericson
Co-authored-by: Théophane Hufschmitt <regnat@users.noreply.github.com>
2020-08-24Add constructor for BasicDerivation -> DerivationJohn Ericson
2020-08-23Merge remote-tracking branch 'obsidian/write-derivation-borrow' into HEADJohn Ericson
2020-08-23`writeDerivation` just needs a plain store referenceJohn Ericson
2020-08-21"Downstream placeholders" should not be store pathsJohn Ericson
Insead they should be opaque `/<hash>` like the placeholders we already have.
2020-08-18Merge remote-tracking branch 'upstream/master' into ↵John Ericson
derivation-header-include-order
2020-08-14Merge remote-tracking branch 'upstream/master' into single-ca-drv-buildJohn Ericson
2020-08-14Merge pull request #3875 from obsidiansystems/new-interface-for-path-pathOptEelco Dolstra
Offer a safer interface for path and pathOpt
2020-08-10Merge branch 'small-drv-serialize-cleanup' of github.com:obsidiansystems/nix ↵John Ericson
into single-ca-drv-build
2020-08-10Remove name parameter from `writeDerivation`John Ericson
The name is now stored with the derivation itself.