nix2container icon indicating copy to clipboard operation
nix2container copied to clipboard

establish stable output api using lazy derivations

Open blaggacao opened this issue 2 years ago • 3 comments
trafficstars

use lazyDerivation with the added benenfits as per its docstring

blaggacao avatar Jun 16 '23 00:06 blaggacao

This looks interesting. Any potential drawback of using this?

takeda avatar Aug 19 '23 04:08 takeda

@blaggacao Could you explain more in detail what issue it fixes? (maybe with an example)

nlewo avatar Aug 19 '23 08:08 nlewo

@blaggacao Could you explain more in detail what issue it fixes? (maybe with an example)

It's the different between a clean backyard and a dumpster, sort of.

If you ever had your grievances with about 20 mkDerivation attributes that mostly make no sense of all and you never actually find (e.g. in the repl or during command completion) what you're looking for. If you once had that sort of experience when using Nix, then this is a fix.

The output becomes as clean as it can get, e.g.: (I deliberately remove same-system task scripts such as copyTo* from passthru in divnix/std)

nix-repl> x86_64-linux.cardano-services.oci-images.cardano-services.
x86_64-linux.cardano-services.oci-images.cardano-services.drvPath     x86_64-linux.cardano-services.oci-images.cardano-services.outputName
x86_64-linux.cardano-services.oci-images.cardano-services.image       x86_64-linux.cardano-services.oci-images.cardano-services.outputs
x86_64-linux.cardano-services.oci-images.cardano-services.meta        x86_64-linux.cardano-services.oci-images.cardano-services.system
x86_64-linux.cardano-services.oci-images.cardano-services.name        x86_64-linux.cardano-services.oci-images.cardano-services.type
x86_64-linux.cardano-services.oci-images.cardano-services.out
x86_64-linux.cardano-services.oci-images.cardano-services.outPath

What a relieve for the eye, fresh and veteran, alike!

QED.


But there's more. meta is still evaluated lazily but without triggering evaluation of the now lazy derivation. So, suppose you want to make an inventory of a really big project and you want to collect all meta.description and render them into the second column. This is now cheap. Before, it was expensive. :smile:

Think of this now costing negligible compute:

nix-repl> x86_64-linux.cardano-services.oci-images.cardano-services.meta.description
"Minimal Cardano Services OCI Image"

2 QED.


A much, much better rundown can be found at the source.

blaggacao avatar Aug 28 '23 19:08 blaggacao