Live data from Hacker News

Nix journey part 0: Learning and reference materials

tinkering.xyz

41–50 of 79 posts

Re: Nix journey part 0: Learning and reference materials

#41
post #38

Earlier quoted context omitted.

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.

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.

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

#43
post #38

Earlier quoted context omitted.

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.

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.

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

Re: Nix journey part 0: Learning and reference materials

#44

The nix package search website is OK, but it doesn't let you filter by the names of installed binaries. A lot of the time, you have a question like "what nixpkgs attribute do i install in order to get the `python3` command". I recently wrote a command line tool that allows you to do this. It uses the same elasticsearch index as the search website, but allows more powerful filtering. If anyone is thinking of getting i…

nix-locate can also solve that problem

Re: Nix journey part 0: Learning and reference materials

#45
post #44

The nix package search website is OK, but it doesn't let you filter by the names of installed binaries. A lot of the time, you have a question like "what nixpkgs attribute do i install in order to get the `python3` command". I recently wrote a command line tool that allows you to do this. It uses the same elasticsearch index as the search website, but allows more powerful filtering. If anyone is thinking of getting i…

nix-locate can also solve that problem

A naive search is even easier. Right now, on NixOS:

   [nextos@local:~]$ python3
   The program 'python3' is not in your PATH. It is provided by several packages.
   You can make it available in an ephemeral shell by typing one of the following:
     nix-shell -p graalvmCEPackages.graalvm11-ce-full
     nix-shell -p graalvmCEPackages.graalvm17-ce-full
     nix-shell -p graalvmCEPackages.python-installable-svm-java11
     nix-shell -p graalvmCEPackages.python-installable-svm-java17
     nix-shell -p ihaskell
     nix-shell -p python311
     nix-shell -p python311Full
     nix-shell -p python312
     nix-shell -p python38
     nix-shell -p python38Full
     nix-shell -p python39
     nix-shell -p python39Full
     nix-shell -p python3Full
     nix-shell -p python3Minimal
     nix-shell -p qtile
     nix-shell -p sourcehut.python

Re: Nix journey part 0: Learning and reference materials

#46
post #45
post #44

Earlier quoted context omitted.

nix-locate can also solve that problem

A naive search is even easier. Right now, on NixOS: [nextos@local:~]$ python3 The program 'python3' is not in your PATH. It is provided by several packages. You can make it available in an ephemeral shell by typing one of the following: nix-shell -p graalvmCEPackages.graalvm11-ce-full nix-shell -p graalvmCEPackages.graalvm17-ce-full nix-shell -p graalvmCEPackages.python-installable-svm-java11 nix-shell -p graalvmCEPa…

I have zsh installed and it's not doing this. How does one get it to do this?

Re: Nix journey part 0: Learning and reference materials

#47
post #42

What sort of time investment is required to get vaguely competent at nix? Mostly dabble in self hosting stuff and not sure it’s worthwhile.

Been using it for about a year now. It took me a couple months of rebuilding my laptop and homelab in my spare time to really feel comfortable. I'm still no expert at the language but I understand it and have "cookbook" examples in my config repo for most things I want to do.

Re: Nix journey part 0: Learning and reference materials

#48

So, I don't quite grok nix. Am I supposed to use it instead of Ansible and Terraform? Where does it fit exactly?

It's like Ansible but with a proper language, declarative instead of imperative config, a lot less leaky and brittle, a huge amount of pre-made packages and config, and can manage the entire OS. Not really the same class as Ansible actually. I used Ansible at first and it felt super hacky and broke all the time. Nix is light years ahead in reliability and power.

Don't know anything about Terraform.

Re: Nix journey part 0: Learning and reference materials

#49
post #45

Earlier quoted context omitted.

A naive search is even easier. Right now, on NixOS: [nextos@local:~]$ python3 The program 'python3' is not in your PATH. It is provided by several packages. You can make it available in an ephemeral shell by typing one of the following: nix-shell -p graalvmCEPackages.graalvm11-ce-full nix-shell -p graalvmCEPackages.graalvm17-ce-full nix-shell -p graalvmCEPackages.python-installable-svm-java11 nix-shell -p graalvmCEPa…

I have zsh installed and it's not doing this. How does one get it to do this?

Are you using flakes? AFAIK `command-not-found` does not work with them. See https://github.com/NixOS/nixpkgs/issues/171054 and https://discourse.nixos.org/t/why-isnt-there-an-official-bui...

`nix-index` is a flake-compatible alternative: https://github.com/bennofs/nix-index

Re: Nix journey part 0: Learning and reference materials

#50
post #49

Earlier quoted context omitted.

I have zsh installed and it's not doing this. How does one get it to do this?

Are you using flakes? AFAIK `command-not-found` does not work with them. See https://github.com/NixOS/nixpkgs/issues/171054 and https://discourse.nixos.org/t/why-isnt-there-an-official-bui... `nix-index` is a flake-compatible alternative: https://github.com/bennofs/nix-index

[deleted]
Post reply on HN