12 /* Extension of derivations in the Nix store. */
13 const string drvExtension
= ".drv";
16 /* Abstract syntax of derivations. */
18 struct DerivationOutput
21 string hashAlgo
; /* hash used for expected hash computation */
22 string hash
; /* expected hash, may be null */
26 DerivationOutput(Path path
, string hashAlgo
, string hash
)
29 this->hashAlgo
= hashAlgo
;
32 void parseHashInfo(bool & recursive
, HashType
& hashType
, Hash
& hash
) const;
35 typedef std::map
<string
, DerivationOutput
> DerivationOutputs
;
37 /* For inputs that are sub-derivations, we specify exactly which
38 output IDs we are interested in. */
39 typedef std::map
<Path
, StringSet
> DerivationInputs
;
41 typedef std::map
<string
, string
> StringPairs
;
45 DerivationOutputs outputs
; /* keyed on symbolic IDs */
46 DerivationInputs inputDrvs
; /* inputs that are sub-derivations */
47 PathSet inputSrcs
; /* inputs that are sources */
58 /* Write a derivation to the Nix store, and return its path. */
59 Path
writeDerivation(StoreAPI
& store
,
60 const Derivation
& drv
, const string
& name
, bool repair
= false);
62 /* Read a derivation from a file. */
63 Derivation
readDerivation(const Path
& drvPath
);
65 /* Print a derivation. */
66 string
unparseDerivation(const Derivation
& drv
);
68 /* Check whether a file name ends with the extensions for
70 bool isDerivation(const string
& fileName
);
72 /* Return true iff this is a fixed-output derivation. */
73 bool isFixedOutputDrv(const Derivation
& drv
);
75 Hash
hashDerivationModulo(StoreAPI
& store
, Derivation drv
);
77 /* Memoisation of hashDerivationModulo(). */
78 typedef std::map
<Path
, Hash
> DrvHashes
;
80 extern DrvHashes drvHashes
;
82 /* Split a string specifying a derivation and a set of outputs
83 (/nix/store/hash-foo!out1,out2,...) into the derivation path and
85 typedef std::pair
<string
, std::set
<string
> > DrvPathWithOutputs
;
86 DrvPathWithOutputs
parseDrvPathWithOutputs(const string
& s
);
88 Path
makeDrvPathWithOutputs(const Path
& drvPath
, const std::set
<string
> & outputs
);
90 bool wantOutput(const string
& output
, const std::set
<string
> & wanted
);
92 PathSet
outputPaths(const Derivation
& drv
);