News for hackers. Stuff that matters.
Re:Nix journey part 0: Learning and reference materials by aidenn0 on Wednesday March 01, 2023 @07:11PM (#34990210)
I've used nix-index to answer this question:

         $ nix-locate --top-level /bin/python3
    remarkable2-toolchain.out                             0 s /nix/store/lygxp772hm743v33wbri22f2k78k1vsb-remarkable2-toolchain-3.1.2/sysroots/cortexa7hf-neon-remarkable-linux-gnueabi/usr/bin/python3
    remarkable2-toolchain.out                             0 s /nix/store/lygxp772hm743v33wbri22f2k78k1vsb-remarkable2-toolchain-3.1.2/sysroots/cortexa7hf-neon-remarkable-linux-gnueabi/usr/bin/python3-config
    remarkable2-toolchain.out                         5,544 x /nix/store/lygxp772hm743v33wbri22f2k78k1vsb-remarkable2-toolchain-3.1.2/sysroots/cortexa7hf-neon-remarkable-linux-gnueabi/usr/bin/python3.8
    remarkable2-toolchain.out                             0 s /nix/store/lygxp772hm743v33wbri22f2k78k1vsb-remarkable2-toolchain-3.1.2/sysroots/cortexa7hf-neon-remarkable-linux-gnueabi/usr/bin/python3.8-config
    remarkable2-toolchain.out                         2,114 x /nix/store/lygxp772hm743v33wbri22f2k78k1vsb-remarkable2-toolchain-3.1.2/sysroots/cortexa7hf-neon-remarkable-linux-gnueabi/usr/bin/python3.8-config-lib
    remarkable2-toolchain.out                             0 s /nix/store/lygxp772hm743v33wbri22f2k78k1vsb-remarkable2-toolchain-3.1.2/sysroots/x86_64-codexsdk-linux/usr/bin/python3
    remarkable2-toolchain.out                           306 x /nix/store/lygxp772hm743v33wbri22f2k78k1vsb-remarkable2-toolchain-3.1.2/sysroots/x86_64-codexsdk-linux/usr/bin/python3.8
    remarkable2-toolchain.out                        18,432 x /nix/store/lygxp772hm743v33wbri22f2k78k1vsb-remarkable2-toolchain-3.1.2/sysroots/x86_64-codexsdk-linux/usr/bin/python3.8.real
    remarkable-toolchain.out                              0 s /nix/store/qk2p0ahd3nndi2zlwm9d0psahlrpikm0-remarkable-toolchain-3.1.2/sysroots/cortexa9hf-neon-remarkable-linux-gnueabi/usr/bin/python3
    remarkable-toolchain.out                              0 s /nix/store/qk2p0ahd3nndi2zlwm9d0psahlrpikm0-remarkable-toolchain-3.1.2/sysroots/cortexa9hf-neon-remarkable-linux-gnueabi/usr/bin/python3-config
    remarkable-toolchain.out                          5,544 x /nix/store/qk2p0ahd3nndi2zlwm9d0psahlrpikm0-remarkable-toolchain-3.1.2/sysroots/cortexa9hf-neon-remarkable-linux-gnueabi/usr/bin/python3.8
    remarkable-toolchain.out                              0 s /nix/store/qk2p0ahd3nndi2zlwm9d0psahlrpikm0-remarkable-toolchain-3.1.2/sysroots/cortexa9hf-neon-remarkable-linux-gnueabi/usr/bin/python3.8-config
    remarkable-toolchain.out                          2,114 x /nix/store/qk2p0ahd3nndi2zlwm9d0psahlrpikm0-remarkable-toolchain-3.1.2/sysroots/cortexa9hf-neon-remarkable-linux-gnueabi/usr/bin/python3.8-config-lib
    remarkable-toolchain.out                              0 s /nix/store/qk2p0ahd3nndi2zlwm9d0psahlrpikm0-remarkable-toolchain-3.1.2/sysroots/x86_64-codexsdk-linux/usr/bin/python3
    remarkable-toolchain.out                            306 x /nix/store/qk2p0ahd3nndi2zlwm9d0psahlrpikm0-remarkable-toolchain-3.1.2/sysroots/x86_64-codexsdk-linux/usr/bin/python3.8
    remarkable-toolchain.out                         18,432 x /nix/store/qk2p0ahd3nndi2zlwm9d0psahlrpikm0-remarkable-toolchain-3.1.2/sysroots/x86_64-codexsdk-linux/usr/bin/python3.8.real
    qtile.out                                        15,872 x /nix/store/mrpll8c98mvnnzab5znqawz56dvq841j-qtile-0.22.1/bin/python3
    qtile.out                                        15,872 x /nix/store/mrpll8c98mvnnzab5znqawz56dvq841j-qtile-0.22.1/bin/python3-config
    qtile.out                                        15,872 x /nix/store/mrpll8c98mvnnzab5znqawz56dvq841j-qtile-0.22.1/bin/python3.10
    qtile.out                                        15,872 x /nix/store/mrpll8c98mvnnzab5znqawz56dvq841j-qtile-0.22.1/bin/python3.10-config
    python3Minimal.out                                    0 s /nix/store/igdcckxrd115041zvvcqmw9qxwf6pfxv-python3-minimal-3.10.8/bin/python3
    python3Minimal.out                               15,616 x /nix/store/igdcckxrd115041zvvcqmw9qxwf6pfxv-python3-minimal-3.10.8/bin/python3.10
    python311.out                                         0 s /nix/store/ipaj21xdmnw2f2bs9mcd7czkzhdhbcfv-python3-3.11.1/bin/python3
    python311.out                                         0 s /nix/store/ipaj21xdmnw2f2bs9mcd7czkzhdhbcfv-python3-3.11.1/bin/python3-config
    python311.out                                    15,616 x /nix/store/ipaj21xdmnw2f2bs9mcd7czkzhdhbcfv-python3-3.11.1/bin/python3.11
    python311.out                                     3,404 x /nix/store/ipaj21xdmnw2f2bs9mcd7czkzhdhbcfv-python3-3.11.1/bin/python3.11-config
    python38.out                                          0 s /nix/store/n3ma7kwpssmwlgv118pc6k5ia0splp2m-python3-3.8.16/bin/python3
    python38.out                                          0 s /nix/store/n3ma7kwpssmwlgv118pc6k5ia0splp2m-python3-3.8.16/bin/python3-config
    python38.out                                     15,616 x /nix/store/n3ma7kwpssmwlgv118pc6k5ia0splp2m-python3-3.8.16/bin/python3.8
    python38.out                                      3,444 x /nix/store/n3ma7kwpssmwlgv118pc6k5ia0splp2m-python3-3.8.16/bin/python3.8-config
    python37.out                                          0 s /nix/store/a1gzdpyn8bbp192cavnxl6sa3snjx563-python3-3.7.16/bin/python3
    python37.out                                          0 s /nix/store/a1gzdpyn8bbp192cavnxl6sa3snjx563-python3-3.7.16/bin/python3-config
    python37.out                                     15,616 x /nix/store/a1gzdpyn8bbp192cavnxl6sa3snjx563-python3-3.7.16/bin/python3.7
    python37.out                                          0 s /nix/store/a1gzdpyn8bbp192cavnxl6sa3snjx563-python3-3.7.16/bin/python3.7-config
    python37.out                                     15,616 x /nix/store/a1gzdpyn8bbp192cavnxl6sa3snjx563-python3-3.7.16/bin/python3.7m
    python37.out                                      3,210 x /nix/store/a1gzdpyn8bbp192cavnxl6sa3snjx563-python3-3.7.16/bin/python3.7m-config
    python3Full.out                                       0 s /nix/store/rf7mdhqwpfzj239ylwim4rfqhw4fz52h-python3-3.10.8/bin/python3
    python3Full.out                                       0 s /nix/store/rf7mdhqwpfzj239ylwim4rfqhw4fz52h-python3-3.10.8/bin/python3-config
    python3Full.out                                  15,616 x /nix/store/rf7mdhqwpfzj239ylwim4rfqhw4fz52h-python3-3.10.8/bin/python3.10
    python3Full.out                                   3,447 x /nix/store/rf7mdhqwpfzj239ylwim4rfqhw4fz52h-python3-3.10.8/bin/python3.10-config
    python38Full.out                                      0 s /nix/store/b5yxnf8vq4rdkbz1z8wydhcxz3r1zsg7-python3-3.8.16/bin/python3
    python38Full.out                                      0 s /nix/store/b5yxnf8vq4rdkbz1z8wydhcxz3r1zsg7-python3-3.8.16/bin/python3-config
    python38Full.out                                 15,616 x /nix/store/b5yxnf8vq4rdkbz1z8wydhcxz3r1zsg7-python3-3.8.16/bin/python3.8
    python38Full.out                                  3,444 x /nix/store/b5yxnf8vq4rdkbz1z8wydhcxz3r1zsg7-python3-3.8.16/bin/python3.8-config
    sourcehut.python.out                                  0 s /nix/store/lbn7f0d2k36i4bgfdrjdwj7npy3r3h5d-python3-3.10.8/bin/python3
    sourcehut.python.out                                  0 s /nix/store/lbn7f0d2k36i4bgfdrjdwj7npy3r3h5d-python3-3.10.8/bin/python3-config
    sourcehut.python.out                             15,616 x /nix/store/lbn7f0d2k36i4bgfdrjdwj7npy3r3h5d-python3-3.10.8/bin/python3.10
    sourcehut.python.out                              3,447 x /nix/store/lbn7f0d2k36i4bgfdrjdwj7npy3r3h5d-python3-3.10.8/bin/python3.10-config
    python39Full.out                                      0 s /nix/store/ckxlmknrfn6c55jwnw86ha9440w4a9ff-python3-3.9.15/bin/python3
    python39Full.out                                      0 s /nix/store/ckxlmknrfn6c55jwnw86ha9440w4a9ff-python3-3.9.15/bin/python3-config
    python39Full.out                                 15,616 x /nix/store/ckxlmknrfn6c55jwnw86ha9440w4a9ff-python3-3.9.15/bin/python3.9
    python39Full.out                                  3,444 x /nix/store/ckxlmknrfn6c55jwnw86ha9440w4a9ff-python3-3.9.15/bin/python3.9-config
    python39.out                                          0 s /nix/store/hm6bqikghylrwgvqd42lgghjdq9p3hac-python3-3.9.15/bin/python3
    python39.out                                          0 s /nix/store/hm6bqikghylrwgvqd42lgghjdq9p3hac-python3-3.9.15/bin/python3-config
    python39.out                                     15,616 x /nix/store/hm6bqikghylrwgvqd42lgghjdq9p3hac-python3-3.9.15/bin/python3.9
    python39.out                                      3,444 x /nix/store/hm6bqikghylrwgvqd42lgghjdq9p3hac-python3-3.9.15/bin/python3.9-config
    python37Full.out                                      0 s /nix/store/ys4my3x7wwb6r6mwfkyk6q9pay2jm3dz-python3-3.7.16/bin/python3
    python37Full.out                                      0 s /nix/store/ys4my3x7wwb6r6mwfkyk6q9pay2jm3dz-python3-3.7.16/bin/python3-config
    python37Full.out                                 15,616 x /nix/store/ys4my3x7wwb6r6mwfkyk6q9pay2jm3dz-python3-3.7.16/bin/python3.7
    python37Full.out                                      0 s /nix/store/ys4my3x7wwb6r6mwfkyk6q9pay2jm3dz-python3-3.7.16/bin/python3.7-config
    python37Full.out                                 15,616 x /nix/store/ys4my3x7wwb6r6mwfkyk6q9pay2jm3dz-python3-3.7.16/bin/python3.7m
    python37Full.out                                  3,210 x /nix/store/ys4my3x7wwb6r6mwfkyk6q9pay2jm3dz-python3-3.7.16/bin/python3.7m-config
    ihaskell.out                                        294 x /nix/store/yj8p9gd2irrh0z16d3b0ljv4vps920h7-ihaskell-with-packages/bin/python3
    ihaskell.out                                        301 x /nix/store/yj8p9gd2irrh0z16d3b0ljv4vps920h7-ihaskell-with-packages/bin/python3-config
    ihaskell.out                                        297 x /nix/store/yj8p9gd2irrh0z16d3b0ljv4vps920h7-ihaskell-with-packages/bin/python3.10
    ihaskell.out                                        304 x /nix/store/yj8p9gd2irrh0z16d3b0ljv4vps920h7-ihaskell-with-packages/bin/python3.10-config
    google-cloud-sdk.out                             20,744 x /nix/store/7dw9fdkqs25fiwzq3r2z1y21gc97c8wd-google-cloud-sdk-408.0.1/google-cloud-sdk/platform/bundledpythonunix/bin/python3
    google-cloud-sdk.out                              3,254 x /nix/store/7dw9fdkqs25fiwzq3r2z1y21gc97c8wd-google-cloud-sdk-408.0.1/google-cloud-sdk/platform/bundledpythonunix/bin/python3-config
    google-cloud-sdk.out                             20,744 x /nix/store/7dw9fdkqs25fiwzq3r2z1y21gc97c8wd-google-cloud-sdk-408.0.1/google-cloud-sdk/platform/bundledpythonunix/bin/python3.9
    google-cloud-sdk.out                              3,254 x /nix/store/7dw9fdkqs25fiwzq3r2z1y21gc97c8wd-google-cloud-sdk-408.0.1/google-cloud-sdk/platform/bundledpythonunix/bin/python3.9-config
    google-cloud-sdk-gce.out                         20,744 x /nix/store/b96rpkxpw920sbbswz1xrrrpjdb1f30c-google-cloud-sdk-408.0.1/google-cloud-sdk/platform/bundledpythonunix/bin/python3
    google-cloud-sdk-gce.out                          3,254 x /nix/store/b96rpkxpw920sbbswz1xrrrpjdb1f30c-google-cloud-sdk-408.0.1/google-cloud-sdk/platform/bundledpythonunix/bin/python3-config
    google-cloud-sdk-gce.out                         20,744 x /nix/store/b96rpkxpw920sbbswz1xrrrpjdb1f30c-google-cloud-sdk-408.0.1/google-cloud-sdk/platform/bundledpythonunix/bin/python3.9
    google-cloud-sdk-gce.out                          3,254 x
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