NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
11.52k stars 1.45k forks source link

Add a `--tree` cli flag for evaluating a Nix file from an arbitrary fetchTree URL #10047

Open thufschmitt opened 4 months ago

thufschmitt commented 4 months ago

One of the killer features of flakes is Flakerefs which allow to directly refer to a – potentially remote – Nix expression from the command-line very concisely (nix run nixpkgs#hello). Most of that is however not flake-specific, but just pertains to the fetchers infrastructure which gives this URL-ish syntax for accessing remote resources[^1]. We can easily bring that to old-style Nix expressions with a new CLI syntax --tree <treeRef>#attr.path that would be morally equivalent to --file $(nix flake prefetch <treeRef>) attr.path.

We can then remove the NIX_PATH=flake:<flakeref> hack as it won't be needed any more (removing it is OK because although it's exposed to the old CLI, it depends on Flakes to be enabled).

[^1]: There is actually a hack that allows having flake:<flakeref> in NIX_PATH to fetch a remote fetcher ref from the network without really using flakes

nixos-discourse commented 4 months ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-02-19-nix-team-meeting-minutes-126/40308/1