Why is `<nixpkgs>` not resolved in `--include nixos-config=`?

Looking at sd-image-aarch64.nix, I had thought that I would be able to build an sdImage like so (without --dry-run obviously):

# nix build --dry-run --file '<nixpkgs/nixos>' --include nixos-config='<nixpkgs/nixos/modules/installer/sd-card/sd-image-aarch64.nix>' config.system.build.sdImage

However, it fails with a warning: warning: Nix search path entry '<nixpkgs/nixos/modules/installer/sd-card/sd-image-aarch64.nix>' does not exist, ignoring

Why doesn’t it resolve <nixpkgs> when passed in as -I nixos-config=<nixpkgs>?

It works if I manually resolve it:

# printenv NIX_PATH
/root/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
# nix build --dry-run --file '<nixpkgs/nixos>' --include nixos-config='/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/installer/sd-card/sd-image-aarch64.nix' config.system.build.sdImage
... works ...

And also seems to work if I pass it in like this:

# nix build --dry-run --file '<nixpkgs/nixos>' --arg configuration '<nixpkgs/nixos/modules/installer/sd-card/sd-image-aarch64.nix>' config.system.build.sdImage
... works ...

But just doesn’t seem to like -I nixos-config=<nixpkgs/...>.

Answer by @chkno on IRC – many thanks!

13:41 < chkno> n8henrie: Because <searchpath> is Nix expression syntax and --include treats its arguments as file
               paths, not Nix expressions to be evaluated.  But --arg is evaluated as a nix expression, so you could
               do it this way: `nix build --dry-run --file '<nixpkgs/nixos>' --arg configuration
               '<nixpkgs/nixos/modules/installer/sd-card/sd-image-aarch64.nix>' config.system.build.sdImage`