Nix: Replace channel with c when resolving URIs?

Created on 12 Sep 2018  路  1Comment  路  Source: NixOS/nix

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.

Most helpful comment

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.

>All comments

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.

Was this page helpful?
0 / 5 - 0 ratings