Skip to content

fetch-tree-powered nix-run #14992

@KiaraGrouwstra

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

flakes

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliThe old and/or new command line interfacefeatureFeature request or proposalnew-cliRelating to the "nix" command

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions