My typical work day require me to build lot of packages with different nixpkgs versions. using -I nixpkgs=channel:nixos-18.03 is an awesome shortcut but I find myself typing it over and over again. Sometimes I even need two nixpkgs versions in the same build command!
I suggest to replace channel:nixos-18.03 with c:nixos-18.03 or even better -I nixpkgs=channel:nixos-18.03 with -I nixpkgs=18.03. I understand though that the latter can cause issues resolving local paths. And that it also incompatible with darwin channels.
While this doesn't address the issue within nix itself, you could also consider creating shell functions/wrappers like
with-18.03() {
env "NIX_PATH=nixpkgs=channel:18.03:$NIX_PATH" -- "$@"
}
or a script (for use outside interactive shells) like
#!/bin/sh
exec env "NIX_PATH=nixpkgs=channel:18.03:$NIX_PATH" -- "$@"
to allow running commands like with-18.03 nix-build.
Most helpful comment
While this doesn't address the issue within nix itself, you could also consider creating shell functions/wrappers like
or a script (for use outside interactive shells) like
to allow running commands like
with-18.03 nix-build.