gnu: solaar: Update to 1.0.6.
[jackhill/guix/guix.git] / nix / libstore / derivations.hh
CommitLineData
36457566
LC
1#pragma once
2
3#include "types.hh"
4#include "hash.hh"
5
6#include <map>
7
8
9namespace nix {
10
11
12/* Extension of derivations in the Nix store. */
13const string drvExtension = ".drv";
14
15
16/* Abstract syntax of derivations. */
17
18struct DerivationOutput
19{
20 Path path;
21 string hashAlgo; /* hash used for expected hash computation */
22 string hash; /* expected hash, may be null */
23 DerivationOutput()
24 {
25 }
26 DerivationOutput(Path path, string hashAlgo, string hash)
27 {
28 this->path = path;
29 this->hashAlgo = hashAlgo;
30 this->hash = hash;
31 }
32 void parseHashInfo(bool & recursive, HashType & hashType, Hash & hash) const;
33};
34
35typedef std::map<string, DerivationOutput> DerivationOutputs;
36
37/* For inputs that are sub-derivations, we specify exactly which
38 output IDs we are interested in. */
39typedef std::map<Path, StringSet> DerivationInputs;
40
41typedef std::map<string, string> StringPairs;
42
43struct Derivation
44{
45 DerivationOutputs outputs; /* keyed on symbolic IDs */
46 DerivationInputs inputDrvs; /* inputs that are sub-derivations */
47 PathSet inputSrcs; /* inputs that are sources */
48 string platform;
49 Path builder;
50 Strings args;
51 StringPairs env;
52};
53
54
55class StoreAPI;
56
57
58/* Write a derivation to the Nix store, and return its path. */
59Path writeDerivation(StoreAPI & store,
60 const Derivation & drv, const string & name, bool repair = false);
61
15ddeff5
LC
62/* Read a derivation from a file. */
63Derivation readDerivation(const Path & drvPath);
36457566
LC
64
65/* Print a derivation. */
66string unparseDerivation(const Derivation & drv);
67
68/* Check whether a file name ends with the extensions for
69 derivations. */
70bool isDerivation(const string & fileName);
71
72/* Return true iff this is a fixed-output derivation. */
73bool isFixedOutputDrv(const Derivation & drv);
74
75Hash hashDerivationModulo(StoreAPI & store, Derivation drv);
76
77/* Memoisation of hashDerivationModulo(). */
78typedef std::map<Path, Hash> DrvHashes;
79
80extern DrvHashes drvHashes;
81
82/* Split a string specifying a derivation and a set of outputs
83 (/nix/store/hash-foo!out1,out2,...) into the derivation path and
84 the outputs. */
85typedef std::pair<string, std::set<string> > DrvPathWithOutputs;
86DrvPathWithOutputs parseDrvPathWithOutputs(const string & s);
87
88Path makeDrvPathWithOutputs(const Path & drvPath, const std::set<string> & outputs);
89
90bool wantOutput(const string & output, const std::set<string> & wanted);
91
322eeb87 92PathSet outputPaths(const Derivation & drv);
36457566
LC
93
94}