1 : #ifndef __DERIVATIONS_H
2 : #define __DERIVATIONS_H
3 :
4 : typedef struct _ATerm * ATerm;
5 :
6 : #include "hash.hh"
7 :
8 : #include <map>
9 :
10 :
11 : namespace nix {
12 :
13 :
14 : /* Extension of derivations in the Nix store. */
15 7897 : const string drvExtension = ".drv";
16 :
17 :
18 : /* Abstract syntax of derivations. */
19 :
20 : struct DerivationOutput
21 5855 : {
22 : Path path;
23 : string hashAlgo; /* hash used for expected hash computation */
24 : string hash; /* expected hash, may be null */
25 1059 : DerivationOutput()
26 1059 : {
27 1059 : }
28 358 : DerivationOutput(Path path, string hashAlgo, string hash)
29 358 : {
30 358 : this->path = path;
31 358 : this->hashAlgo = hashAlgo;
32 358 : this->hash = hash;
33 358 : }
34 : };
35 :
36 : typedef std::map<string, DerivationOutput> DerivationOutputs;
37 :
38 : /* For inputs that are sub-derivations, we specify exactly which
39 : output IDs we are interested in. */
40 : typedef std::map<Path, StringSet> DerivationInputs;
41 :
42 : typedef std::map<string, string> StringPairs;
43 :
44 : struct Derivation
45 2625 : {
46 : DerivationOutputs outputs; /* keyed on symbolic IDs */
47 : DerivationInputs inputDrvs; /* inputs that are sub-derivations */
48 : PathSet inputSrcs; /* inputs that are sources */
49 : string platform;
50 : Path builder;
51 : Strings args;
52 : StringPairs env;
53 : };
54 :
55 :
56 : /* Hash an aterm. */
57 : Hash hashTerm(ATerm t);
58 :
59 : /* Write a derivation to the Nix store, and return its path. */
60 : Path writeDerivation(const Derivation & drv, const string & name);
61 :
62 : /* Parse a derivation. */
63 : Derivation parseDerivation(ATerm t);
64 :
65 : /* Parse a derivation. */
66 : ATerm unparseDerivation(const Derivation & drv);
67 :
68 : /* Check whether a file name ends with the extensions for
69 : derivations. */
70 : bool isDerivation(const string & fileName);
71 :
72 :
73 : }
74 :
75 :
76 : #endif /* !__DERIVATIONS_H */
|