-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More context in context string #4677
Comments
I marked this as stale due to inactivity. → More info |
In NixOS/nixpkgs#140792, Yet another idea is to allow the context to be extended such that a string can not be written to the store. This could make Nix much safer as a configuration language, allowing secret strings to be marked as such.
This will usually be limited to thunks that reference already existing heap objects, so I would estimate that it's only a small number of extra heap objects per instantiated package. More good news is that it is compatible with evaluation caching. The string context could be modeled the same as an attribute set in this regard. |
This highlights somewhat of a problem with Nixpkgs, but this change is not a regression in this regard. If a package repository can be structured to avoid referencing packages for too long, it can also restrict the information it adds to the context to a small amount and force evaluation of that information using |
Is your feature request related to a problem? Please describe.
I'm gathering informations about all the dependencies of a project, such as licences, maintainers, kind (i.e. haskell deps, python deps, ...) and count of the dependencies, ...
It is straightforward to walk the nix structures and gather some information.
builtins.genericClosure
helps. However I'm missing the dependencies which are implicitly attached to string as string context.I can recover the context using
builtins.getContext
, however it does returns a path in the nix store to the derivation, not the original attribute set, so the information I care about is lost.For example, the expression
pkgs.runCommand "foo" {} ''${pkgs.blender}''
implicitly depends onpkgs.blender
. However I cannot find a reference to the derivationblender
other than usingbuiltins.getContext ((pkgs.runCommand "foo" {} ''${pkgs.blender}'').buildCommand)
which returns an attribute set where thedrv
path is the key:{ "/nix/store/8vwn856hd9q6413qqnjiv3l4x7wxq31r-blender-2.91.0.drv" = { ... }; }
, unfortunately, the derivation attribute set is lost, including themeta
information I care about.Unfortunately, the
.drv
does not contain themeta
information either.Describe the solution you'd like
The string context could include a reference to the original derivation which was interpolated as a path?
Describe alternatives you've considered
.drv
path, by looking in all the derivation of my projects (includingnixpkgs
), but it is slow (i.e. I need to generate the attribute set of ALL the possible outputPath) and it may not be complete, if a derivation does not exists as an explicit nix reference somewhere (e.g."${pkgs.blender}"
will be found when scanningpkgs
, but"${pkgs.f x y}"
won't, because onlyf
will be found when scanningpkgs
.)Additional context
The issue with this approach is that it will cost memory for the new entry in the context as well as keeping a reference to the associated attribute set. I did not estimated the memory overhead introduced.
The text was updated successfully, but these errors were encountered: