Skip to content

fetch-tree-powered nix-run #14992

Open
Open

Description

@KiaraGrouwstra

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-run for use like nix-run github:nixos/nixpkgs?ref=nixos-25.11#hello (i.e. arguments like nix 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

Additional context

  • in my testing this could also work with nix registry
  • while commands like nix-shell with say nix-shell -p hello might similarly use nixpkgs, in that case to build packages from, it's maybe another question whether it makes sense to depend on nixpkgs' lib.getExe within nix core. i'm not sure how that works for nix-shell - maybe a similar relation to the one taken there could work here as well. maybe. nix run seems prior art on getExe-like considerations.

Checklist


Add 👍 to issues you find important.

Activity

  1. added
    feature
    on Jan 14, 2026
  2. roberth commented on Jan 15, 2026

    @roberth
    Member

    nix run -f is pretty close, except lacking fetchTree.
    I suppose something similar to the NIX_PATH=nixpkgs=flake:github:... feature could be done for CLI arguments, renaming flake: to the more accurate tree: 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#hello
  3. added
    new-cli
    cli
    on Jan 15, 2026
  4. KiaraGrouwstra commented on Feb 6, 2026

    @KiaraGrouwstra
    ContributorAuthor

    c.f. nix-run

  5. nixos-discourse commented on Feb 6, 2026

    @nixos-discourse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    clifeaturenew-cli

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions