Open the Nix expression of a Nix package in $EDITOR. More information: https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-edit.html.
$EDITOR
nix edit nixpkgs#pkg
stdout
EDITOR=cat nix edit nixpkgs#pkg