News for hackers. Stuff that matters.
Re:Nix journey part 0: Learning and reference materials by aidenn0 on Wednesday March 01, 2023 @07:18PM (#34990269)
Previous comment is getting long, but if you want to get rid of things like "googlecloud-sdk/platform/bundledpythonunix/bin" you can use:

    nix-locate --top-level --regex '^/bin/python3'
Which will only show packages with "/bin/python3" in the root.

Most of the time this is unnecessary, but since python gets vendored in a lot of packages, it comes up with this example.

Re:Nix journey part 0: Learning and reference materials by peter_l_downs on Wednesday March 01, 2023 @07:21PM (#34990299)
I can't tell if you're joking, but I'm not sure how these results told you anything. I find nix-index and nix-locate entirely unusable.
Re:Nix journey part 0: Learning and reference materials by aidenn0 on Wednesday March 01, 2023 @07:24PM (#34990323)
Not joking, I just scan through the first column. If you want to not have to do so, adding -1 cleans it up:

    $ nix-locate --top-level -1 --regex '^/bin/python3'
    qtile.out
    python3Minimal.out
    python311.out
    python38.out
    python37.out
    python3Full.out
    python38Full.out
    sourcehut.python.out
    python39Full.out
    python39.out
    python37Full.out
    ihaskell.out
Also things like "python3" and "gcc" and such are going to show way more hits than, for example, "firefox":

    $ nix-locate --top-level -1 --regex '^/bin/firefox'
    firefox-esr-102-unwrapped.out
    firefox_decrypt.out
    firefox-unwrapped.out
    firefox.out
Re:Nix journey part 0: Learning and reference materials by aidenn0 on Wednesday March 01, 2023 @08:01PM (#34990588)
Here, I made a short shell script to show all the results with package descriptions (requires enabling the "nix" command):

    #!/bin/sh
    results="$(nix-locate -1 --regex --top-level "^/bin/${1}\$")"
    for item in $results; do
        nix search "nixpkgs#${item%.*}"
    done
Example:

    $ ./nix-find-executable.sh python3
    * legacyPackages.x86_64-linux.qtile (0.22.1)
      A small, flexible, scriptable tiling window manager written in Python
    * legacyPackages.x86_64-linux.python3Minimal (3.10.8)
      A high-level dynamically-typed programming language
    * legacyPackages.x86_64-linux.python311 (3.11.1)
      A high-level dynamically-typed programming language
    * legacyPackages.x86_64-linux.python38 (3.8.16)
      A high-level dynamically-typed programming language
    * legacyPackages.x86_64-linux.python37 (3.7.16)
      A high-level dynamically-typed programming language
    * legacyPackages.x86_64-linux.python3Full (3.10.8)
      A high-level dynamically-typed programming language
    * legacyPackages.x86_64-linux.python38Full (3.8.16)
      A high-level dynamically-typed programming language
    * legacyPackages.x86_64-linux.sourcehut.python (3.10.8)
      A high-level dynamically-typed programming language
    * legacyPackages.x86_64-linux.python39Full (3.9.15)
      A high-level dynamically-typed programming language
    * legacyPackages.x86_64-linux.python39 (3.9.15)
      A high-level dynamically-typed programming language
    * legacyPackages.x86_64-linux.python37Full (3.7.16)
      A high-level dynamically-typed programming language
    * legacyPackages.x86_64-linux.ihaskell