How to access implicit derivation arguments?

I have a derivation which I would like to pass command line arguments to without enumerating all the different possibilities. In principle the @ operator should do what I want.

args@{ explicit, ... }:
with import <nixpkgs> {};
builtins.trace "${builtins.toJSON args}"
stdenv.mkDerivation { name = "test"; }

However, when instantiating this derivation I get

$ nix-instantiate test.nix --argstr explicit "explicit" --argstr implicit "implicit"
trace: {"explicit":"explicit"}
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
/nix/store/kfp1phrjhqvp47qi8y1gkfaqhaj6f48c-test.drv

So the args attribute set does not contain the implicit parameter. Why is that and what can I do about it?

Exactly this is possible with a recent nix PR :slight_smile:

1 Like

I see, thank you very much. Unfortunately, this doesnโ€™t seem to be in Nix stable, so for now I have to resort to things like this:

$ nix-instantiate -E 'import ./test.nix { explicit = "explicit"; implicit = "implicit"; }'
trace: {"explicit":"explicit","implicit":"implicit"}
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
/nix/store/kfp1phrjhqvp47qi8y1gkfaqhaj6f48c-test.drv