322eeb87d0
This is a squashed commit of the following: commit0dccab9f41
Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Jul 2 00:30:16 2015 +0200 Typo commit2cd28517b1
Author: Ludovic Courtès <ludo@gnu.org> Date: Wed Jul 1 14:56:34 2015 +0200 Preserve supplementary groups of build users The following patch is an attempt to address this bug (see <http://bugs.gnu.org/18994>) by preserving the supplementary groups of build users in the build environment. In practice, I would expect that supplementary groups would contain only one or two groups: the build users group, and possibly the “kvm” group. [Changed &at(0) to data() and removed tabs - Eelco] commit6e38685ef6
Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Jun 30 21:41:26 2015 +0200 GC: Handle ENOSPC creating/moving to the trash directory Issue #564. commit5e0a9ae2e2
Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Jun 22 15:54:55 2015 +0200 Use posix_fallocate to create /nix/var/nix/db/reserved commit4e5ab98d6d
Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Jun 22 15:47:40 2015 +0200 Make /nix/var/nix/db/reserved bigger Issue #564. commit60bda60fc0
Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Wed Jun 10 16:17:06 2015 +0200 Export outputPaths function This is useful for the new hydra-queue-runner. commit5dfea34048
Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Jul 2 22:51:33 2015 +0200 Use std::vector::data() commit2459458bc8
Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Jun 4 16:04:41 2015 +0200 Allow substitutes for builds that have preferLocalBuild set Not substituting builds with "preferLocalBuild = true" was a bad idea, because it didn't take the cost of dependencies into account. For instance, if we can't substitute a fetchgit call, then we have to download/build git and all its dependencies. Partially reverts5558652709
and adds a new derivation attribute "allowSubstitutes" to specify whether a derivation may be substituted.
94 lines
2.4 KiB
C++
94 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include "types.hh"
|
|
#include "hash.hh"
|
|
|
|
#include <map>
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
/* Extension of derivations in the Nix store. */
|
|
const string drvExtension = ".drv";
|
|
|
|
|
|
/* Abstract syntax of derivations. */
|
|
|
|
struct DerivationOutput
|
|
{
|
|
Path path;
|
|
string hashAlgo; /* hash used for expected hash computation */
|
|
string hash; /* expected hash, may be null */
|
|
DerivationOutput()
|
|
{
|
|
}
|
|
DerivationOutput(Path path, string hashAlgo, string hash)
|
|
{
|
|
this->path = path;
|
|
this->hashAlgo = hashAlgo;
|
|
this->hash = hash;
|
|
}
|
|
void parseHashInfo(bool & recursive, HashType & hashType, Hash & hash) const;
|
|
};
|
|
|
|
typedef std::map<string, DerivationOutput> DerivationOutputs;
|
|
|
|
/* For inputs that are sub-derivations, we specify exactly which
|
|
output IDs we are interested in. */
|
|
typedef std::map<Path, StringSet> DerivationInputs;
|
|
|
|
typedef std::map<string, string> StringPairs;
|
|
|
|
struct Derivation
|
|
{
|
|
DerivationOutputs outputs; /* keyed on symbolic IDs */
|
|
DerivationInputs inputDrvs; /* inputs that are sub-derivations */
|
|
PathSet inputSrcs; /* inputs that are sources */
|
|
string platform;
|
|
Path builder;
|
|
Strings args;
|
|
StringPairs env;
|
|
};
|
|
|
|
|
|
class StoreAPI;
|
|
|
|
|
|
/* Write a derivation to the Nix store, and return its path. */
|
|
Path writeDerivation(StoreAPI & store,
|
|
const Derivation & drv, const string & name, bool repair = false);
|
|
|
|
/* Read a derivation from a file. */
|
|
Derivation readDerivation(const Path & drvPath);
|
|
|
|
/* Print a derivation. */
|
|
string unparseDerivation(const Derivation & drv);
|
|
|
|
/* Check whether a file name ends with the extensions for
|
|
derivations. */
|
|
bool isDerivation(const string & fileName);
|
|
|
|
/* Return true iff this is a fixed-output derivation. */
|
|
bool isFixedOutputDrv(const Derivation & drv);
|
|
|
|
Hash hashDerivationModulo(StoreAPI & store, Derivation drv);
|
|
|
|
/* Memoisation of hashDerivationModulo(). */
|
|
typedef std::map<Path, Hash> DrvHashes;
|
|
|
|
extern DrvHashes drvHashes;
|
|
|
|
/* Split a string specifying a derivation and a set of outputs
|
|
(/nix/store/hash-foo!out1,out2,...) into the derivation path and
|
|
the outputs. */
|
|
typedef std::pair<string, std::set<string> > DrvPathWithOutputs;
|
|
DrvPathWithOutputs parseDrvPathWithOutputs(const string & s);
|
|
|
|
Path makeDrvPathWithOutputs(const Path & drvPath, const std::set<string> & outputs);
|
|
|
|
bool wantOutput(const string & output, const std::set<string> & wanted);
|
|
|
|
PathSet outputPaths(const Derivation & drv);
|
|
|
|
}
|