aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/derivations.hh
AgeCommit message (Collapse)Author
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.
2020-08-07Squashed get CA derivations buildingJohn Ericson
2020-08-05Merge branch 'master' of github.com:NixOS/nix into ↵Carlo Nucera
new-interface-for-path-pathOpt
2020-08-05Reanme `DerivationType::Regular` defintion tooJohn Ericson
This is the one non-prefixed occurence
2020-08-05Make names more consistentJohn Ericson
2020-08-01Merge remote-tracking branch 'upstream/master' into ↵John Ericson
derivation-header-include-order
2020-07-28Offer a safer interface for pathOptCarlo Nucera
The new interface we offer provides a way of getting all the DerivationOutputs with the storePaths directly, based on the observation that it's the most common usecase.
2020-07-27Merge remote-tracking branch 'upstream/master' into ↵John Ericson
optional-derivation-output-storepath
2020-07-23Merge remote-tracking branch 'upstream/master' into misc-caJohn Ericson
2020-07-23Get rid of `basicDerivation::findOutput`John Ericson
It's a tiny function which is: - hardly worth abstrating over, and also only used once. - doesn't work once we get CA drvs I rewrote the one callsite to be forwards compatable with CA derivations, and also potentially more performant: instead of reading in the derivation it can ust consult the SQLite DB in the common case.
2020-07-20Merge branch 'ca-derivation-data-types' of github.com:obsidiansystems/nix ↵Carlo Nucera
into misc-ca