Shorter nix run with overrides

Hi, is there a shortcut for running the following?

nix run --impure --expr '(builtins.getFlake "github:nixos/nixpkgs/nixpkgs-unstable").legacyPackages."${builtins.currentSystem}".nnn.override {withNerdIcons = true;}'

I mean it’s great that this is still a one-liner but maybe it’s possible to call overrides with the regular nix run nixpkgs#something syntax somehow?

Obviously I tried:

$ nix run 'nixpkgs#nnn.override {withNerdIcons = true;}'
error: 'nixpkgs#nnn.override {withNerdIcons = true;}' is not a valid URL
1 Like

nix eval has the --apply option, but afaik it’s only applicable to nix eval. That’s the only thing I can think of that even might help with this, I’m afraid.


That’s cool, so I can do:

nix eval --raw nixpkgs#nnn --apply 'x: x.override {withNerdIcons = true;}'

which outputs a store path… but doesn’t seem to actually instantiate the derivation? I can’t seem to find any flags to do this.

BTW if I don’t define --raw it goes into an infinite loop saying
trace: warning: Use `stdenv.tests` instead. `passthru` is a `mkDerivation` detail.

I’m just looking for a more ergonomic way to do overrides from the command line is all.
It’s probably not a common thing so it might not be possible at the moment, that’s fine.

nix eval is intended to not actually build things, unless IFD is involved. Which is why I was fairly sure it wouldn’t help.

You should probably submit a feature request for nix, to add --apply functionality to nix build and nix run.