News for hackers. Stuff that matters.
Re:Super Colliding Nix Stores: Nix Flakes for Millions of De... by sterlind on Thursday May 25, 2023 @04:24PM (#36075709)
why does it query search.nixos.org, rather than looking through your local nixpkgs? just because of how tricky it'd be to handle the nix language or hacking on the nix toolchain proper?

also I agree that it's ridiculous nix doesn't have a search command. it baffles me.

Re:Super Colliding Nix Stores: Nix Flakes for Millions of De... by ghuntley on Thursday May 25, 2023 @04:54PM (#36076085)
search.nixos.org also includes flakes that people PR into the index via GitHub at https://github.com/NixOS/nixos-search/issues

ps: $ nix search exists via experimental flags https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3...

Re:Super Colliding Nix Stores: Nix Flakes for Millions of De... by lilyball on Thursday May 25, 2023 @04:55PM (#36076102)
It does though. `nix search`.
Re:Super Colliding Nix Stores: Nix Flakes for Millions of De... by peter_l_downs on Thursday May 25, 2023 @05:11PM (#36076287)
This exists and searches `search.nixos.org` for a few reasons:

- you may want to search without downloading and indexing nixpkgs and the hydra results yourself

- you may want to search by the name of the binaries/programs that will be installed, which is impossible to do by looking through a local package store alone

- you may want the search to be fast

- you may want to search from the command line

`nix search` is a cruel joke which doesn't allow searching by the name/program that would be installed, only package name, and requires a flake name every time. Absolutely terrible interface.

My tool is a single-install binary that performs fast and accurate search to help you find the right package name to install a given binary. I don't understand how after years of using other package managers anyone could want a search tool that does anything other than this by default.

For more details on why this exists, check out https://github.com/peterldowns/nix-search-cli#motivation

Re:Super Colliding Nix Stores: Nix Flakes for Millions of De... by aidenn0 on Thursday May 25, 2023 @06:55PM (#36077504)
Nix has several search commands, it's just none of them do quite what people want (e.g. "nix search" with flakes and "nix-query" without flakes search by name and description, "nix-locate" can search by contents but the interface is a bit obtuse)

For those who want a local search for executables, and don't mind running nix-index:

    #!/bin/sh
    results="$(nix-locate -1 --regex --top-level "^/bin/${1}\$")"
    for item in $results; do
        nix search "nixpkgs#${item%.*}"
    done
will search for a specific executable and give you (hopefully) reasonable output. If you don't have flakes enabled, you can just print the result of the command-substitution directly, but you won't get the short description.