Repository navigation
Open
Description
Is your feature request related to a problem?
it would be nice to have a convenient way to run programs from fetch-tree-accessible (potentially remote) repositories.
Proposed solution
a v2-cli-like command nix-run, functioning perhaps not unlike bash aliases like:
- drop-in
nix-runfor use likenix-run github:nixos/nixpkgs?ref=nixos-25.11#hello(i.e. arguments likenix run's):alias nix-run='run() { $(nix-instantiate --raw --impure --eval --expr "(import <nixpkgs> {}).lib.getExe (import (builtins.fetchTree \"$(cut -d "#" -f 1 <<< "$1")\").outPath { }).$(cut -d "#" -f 2 <<< "$1")"); }; run' - version for use like
nix-run github:nixos/nixpkgs?ref=nixos-25.11 hello(so args spaced):alias nix-run='run() { $(nix-instantiate --raw --impure --eval --expr "(import <nixpkgs> {}).lib.getExe (import (builtins.fetchTree \"$1\").outPath { }).$2"); }; run'
Alternative solutions
- flakes
- v3 cli + Add a
--treecli flag for evaluating a Nix file from an arbitrary fetchTree URL #10047
Additional context
- in my testing this could also work with
nix registry - while commands like
nix-shellwith saynix-shell -p hellomight similarly use nixpkgs, in that case to build packages from, it's maybe another question whether it makes sense to depend on nixpkgs'lib.getExewithin nix core. i'm not sure how that works fornix-shell- maybe a similar relation to the one taken there could work here as well. maybe.nix runseems prior art ongetExe-like considerations.
Checklist
- checked latest Nix manual (source)
- checked open feature issues and pull requests for possible duplicates
Add 👍 to issues you find important.
Reacted by Alin
Reacted by Else, Someone
Activity
roberth commentedon Jan 15, 2026
nix run -fis pretty close, except lackingfetchTree.I suppose something similar to the
NIX_PATH=nixpkgs=flake:github:...feature could be done for CLI arguments, renamingflake:to the more accuratetree:while we're at it.I personally wouldn't mind adding a new "old CLI" command, but we can do achieve this quite nicely in the new CLI as well, and that would have the benefit of furthering progress on the nix-command project.
nix run -f tree:github:nixos/nixpkgs?ref=nixos-25.11#helloKiaraGrouwstra commentedon Feb 6, 2026
c.f.
nix-runnixos-discourse commentedon Feb 6, 2026
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/nix-run-run-nix-derivations-without-nix3-or-flakes/75072/2