aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/parsed-derivations.hh
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2021-05-02 17:24:14 +0200
committerMaximilian Bosch <maximilian@mbosch.me>2021-06-22 19:15:57 +0200
commit3b5429aec110a22f8fe0d92b72faf1921b8ede2d (patch)
treee3e5c646be65cb827fe7e23bd271289e289d53c8 /src/libstore/parsed-derivations.hh
parent4b23bf797a26da2731df0eebf9f121a68cdbd4d6 (diff)
Source complete env in `nix-shell` with `__structuredAttrs = true;`
This is needed to push the adoption of structured attrs[1] forward. It's now checked if a `__json` exists in the environment-map of the derivation to be openend in a `nix-shell`. Derivations with structured attributes enabled also make use of a file named `.attrs.json` containing every environment variable represented as JSON which is useful for e.g. `exportReferencesGraph`[2]. To provide an environment similar to the build sandbox, `nix-shell` now adds a `.attrs.json` to `cwd` (which is mostly equal to the one in the build sandbox) and removes it using an exit hook when closing the shell. To avoid leaking internals of the build-process to the `nix-shell`, the entire logic to generate JSON and shell code for structured attrs was moved into the `ParsedDerivation` class. [1] https://nixos.mayflower.consulting/blog/2020/01/20/structured-attrs/ [2] https://nixos.org/manual/nix/unstable/expressions/advanced-attributes.html#advanced-attributes
Diffstat (limited to 'src/libstore/parsed-derivations.hh')
-rw-r--r--src/libstore/parsed-derivations.hh4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libstore/parsed-derivations.hh b/src/libstore/parsed-derivations.hh
index c9fbe68c4..4b8b8c8ff 100644
--- a/src/libstore/parsed-derivations.hh
+++ b/src/libstore/parsed-derivations.hh
@@ -6,6 +6,8 @@
namespace nix {
+typedef std::pair<std::string, nlohmann::json> StructuredAttrsWithShellRC;
+
class ParsedDerivation
{
StorePath drvPath;
@@ -36,6 +38,8 @@ public:
bool willBuildLocally(Store & localStore) const;
bool substitutesAllowed() const;
+
+ std::optional<StructuredAttrsWithShellRC> generateStructuredAttrs(std::optional<StringMap> inputRewrites, Store & store, const StorePathSet & inputPaths);
};
}