The example below will install yarn without explicitely depending on node, i.e., it will use whatever node version you have available on the environment.
To install simply run
nix-env -f yarn.nix -i.
More generally, when extending a
package.nix, you can follow the template
below and run with
nix-env -f your_file.nix -i