1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 10:50:24 -04:00

Merge branch 'master' of github.com:NixOS/nix into rm-createdirs

This commit is contained in:
siddhantCodes 2024-06-11 19:16:56 +05:30
commit 552a2cee21
6 changed files with 29 additions and 25 deletions

View file

@ -71,10 +71,9 @@
[`__contentAddressed`](./language/advanced-attributes.md#adv-attr-__contentAddressed) [`__contentAddressed`](./language/advanced-attributes.md#adv-attr-__contentAddressed)
attribute set to `true`. attribute set to `true`.
- [fixed-output derivation]{#gloss-fixed-output-derivation} - [fixed-output derivation]{#gloss-fixed-output-derivation} (FOD)
A derivation which includes the A [derivation] where a cryptographic hash of the [output] is determined in advance using the [`outputHash`](./language/advanced-attributes.md#adv-attr-outputHash) attribute, and where the [`builder`](@docroot@/language/derivations.md#attr-builder) executable has access to the network.
[`outputHash`](./language/advanced-attributes.md#adv-attr-outputHash) attribute.
- [store]{#gloss-store} - [store]{#gloss-store}

View file

@ -120,12 +120,11 @@ Derivations can declare some infrequently used optional attributes.
configuration setting. configuration setting.
- [`outputHash`]{#adv-attr-outputHash}; [`outputHashAlgo`]{#adv-attr-outputHashAlgo}; [`outputHashMode`]{#adv-attr-outputHashMode}\ - [`outputHash`]{#adv-attr-outputHash}; [`outputHashAlgo`]{#adv-attr-outputHashAlgo}; [`outputHashMode`]{#adv-attr-outputHashMode}\
These attributes declare that the derivation is a so-called These attributes declare that the derivation is a so-called *fixed-output derivation* (FOD), which means that a cryptographic hash of the output is already known in advance.
*fixed-output derivation*, which means that a cryptographic hash of
the output is already known in advance. When the build of a As opposed to regular derivations, the [`builder`] executable of a fixed-output derivation has access to the network.
fixed-output derivation finishes, Nix computes the cryptographic Nix computes a cryptographic hash of its output and compares that to the hash declared with these attributes.
hash of the output and compares it to the hash declared with these If there is a mismatch, the derivation fails.
attributes. If there is a mismatch, the build fails.
The rationale for fixed-output derivations is derivations such as The rationale for fixed-output derivations is derivations such as
those produced by the `fetchurl` function. This function downloads a those produced by the `fetchurl` function. This function downloads a
@ -279,7 +278,9 @@ Derivations can declare some infrequently used optional attributes.
> **Note** > **Note**
> >
> If set to `false`, the [`builder`](./derivations.md#attr-builder) should be able to run on the system type specified in the [`system` attribute](./derivations.md#attr-system), since the derivation cannot be substituted. > If set to `false`, the [`builder`] should be able to run on the system type specified in the [`system` attribute](./derivations.md#attr-system), since the derivation cannot be substituted.
[`builder`]: ./derivations.md#attr-builder
- [`__structuredAttrs`]{#adv-attr-structuredAttrs}\ - [`__structuredAttrs`]{#adv-attr-structuredAttrs}\
If the special attribute `__structuredAttrs` is set to `true`, the other derivation If the special attribute `__structuredAttrs` is set to `true`, the other derivation

View file

@ -31,7 +31,7 @@ struct CachedEvalError : EvalError
class EvalCache : public std::enable_shared_from_this<EvalCache> class EvalCache : public std::enable_shared_from_this<EvalCache>
{ {
friend class AttrCursor; friend class AttrCursor;
friend class CachedEvalError; friend struct CachedEvalError;
std::shared_ptr<AttrDb> db; std::shared_ptr<AttrDb> db;
EvalState & state; EvalState & state;
@ -87,7 +87,7 @@ typedef std::variant<
class AttrCursor : public std::enable_shared_from_this<AttrCursor> class AttrCursor : public std::enable_shared_from_this<AttrCursor>
{ {
friend class EvalCache; friend class EvalCache;
friend class CachedEvalError; friend struct CachedEvalError;
ref<EvalCache> root; ref<EvalCache> root;
typedef std::optional<std::pair<std::shared_ptr<AttrCursor>, Symbol>> Parent; typedef std::optional<std::pair<std::shared_ptr<AttrCursor>, Symbol>> Parent;

View file

@ -354,7 +354,7 @@ void initGC()
// TODO: Remove __APPLE__ condition. // TODO: Remove __APPLE__ condition.
// Comment suggests an implementation that works on darwin and windows // Comment suggests an implementation that works on darwin and windows
// https://github.com/ivmai/bdwgc/issues/362#issuecomment-1936672196 // https://github.com/ivmai/bdwgc/issues/362#issuecomment-1936672196
#if GC_VERSION_MAJOR >= 8 && GC_VERSION_MINOR >= 4 && !defined(__APPLE__) #if GC_VERSION_MAJOR >= 8 && GC_VERSION_MINOR >= 2 && GC_VERSION_MICRO >= 4 && !defined(__APPLE__)
GC_set_sp_corrector(&fixupBoehmStackPointer); GC_set_sp_corrector(&fixupBoehmStackPointer);
if (!GC_get_sp_corrector()) { if (!GC_get_sp_corrector()) {
@ -365,7 +365,7 @@ void initGC()
}; };
} }
#else #else
#warning "BoehmGC version does not support GC while coroutine exists. GC will be disabled inside coroutines. Consider updating bwd-gc to 8.4 or later." #warning "BoehmGC version does not support GC while coroutine exists. GC will be disabled inside coroutines. Consider updating bdw-gc to 8.2.4 or later."
#endif #endif

View file

@ -4062,17 +4062,23 @@ static RegisterPrimOp primop_convertHash({
struct RegexCache struct RegexCache
{ {
// TODO use C++20 transparent comparison when available struct State
std::unordered_map<std::string_view, std::regex> cache; {
std::list<std::string> keys; // TODO use C++20 transparent comparison when available
std::unordered_map<std::string_view, std::regex> cache;
std::list<std::string> keys;
};
Sync<State> state_;
std::regex get(std::string_view re) std::regex get(std::string_view re)
{ {
auto it = cache.find(re); auto state(state_.lock());
if (it != cache.end()) auto it = state->cache.find(re);
if (it != state->cache.end())
return it->second; return it->second;
keys.emplace_back(re); state->keys.emplace_back(re);
return cache.emplace(keys.back(), std::regex(keys.back(), std::regex::extended)).first->second; return state->cache.emplace(state->keys.back(), std::regex(state->keys.back(), std::regex::extended)).first->second;
} }
}; };

View file

@ -477,9 +477,7 @@ static void main_nix_build(int argc, char * * argv)
// Set the environment. // Set the environment.
auto env = getEnv(); auto env = getEnv();
auto tmp = getEnvNonEmpty("TMPDIR"); auto tmp = getEnvNonEmpty("TMPDIR").value_or("/tmp");
if (!tmp)
tmp = getEnvNonEmpty("XDG_RUNTIME_DIR").value_or("/tmp");
if (pure) { if (pure) {
decltype(env) newEnv; decltype(env) newEnv;
@ -491,7 +489,7 @@ static void main_nix_build(int argc, char * * argv)
env["__ETC_PROFILE_SOURCED"] = "1"; env["__ETC_PROFILE_SOURCED"] = "1";
} }
env["NIX_BUILD_TOP"] = env["TMPDIR"] = env["TEMPDIR"] = env["TMP"] = env["TEMP"] = *tmp; env["NIX_BUILD_TOP"] = env["TMPDIR"] = env["TEMPDIR"] = env["TMP"] = env["TEMP"] = tmp;
env["NIX_STORE"] = store->storeDir; env["NIX_STORE"] = store->storeDir;
env["NIX_BUILD_CORES"] = std::to_string(settings.buildCores); env["NIX_BUILD_CORES"] = std::to_string(settings.buildCores);