![]() Rather than install and remove packages as necessary, Nix lets you create a one-off shell that contains a set of packages. The third use case is Nix’s killer feature in my mind. All developers can use the nix-shell command to launch a Bash shell with the appropriate dependencies installed and available.) This use case seems more aspirational than practical since it requires all developers use Nix to get this benefit. These dependencies can be specified in the shell.nix file. (E.g., a Python project may require other Python packages to be installed. Nix’s second use case lets developers declaratively specify a (more or less) complete environment for a project in a shell.nix file. Nix also supports a declarative package management system where you put the list of packages you want in a file and then you can (for example) check that file into version control. Like any good package manager, this will install rg along with any dependencies. For example, if you want to install the excellent ripgrep tool, you’d use the following command. It’s usually used on the command line to install packages incrementally. ![]() The tool for this is called nix-env and it’s responsible for installing packages. One-off shells with packages installed andįor the first use case, I mean package management in the style of Apt, MacPorts, or HomeBrew.In my mind, there are four main use cases for Nix. Nix bills itself as “a tool that takes a unique approach to package management and system configuration” that can be used “to make reproducible, declarative and reliable systems.” The experimental features change so I won’t discuss them at all either. Nix has a bunch of experimental features (including the nix binary itself and flakes 2). In this post, I’m going to stick with running standard Nix binaries and not use any additional tools (although there are two shell scripts that run Nix tools that I find useful at the end of the post). Adding additional tools just makes it harder to understand how Nix works and how to use it directly. If you’re familiar with Nix, you may be wondering, why not use Home Manager? The short answer is Nix is already too complex. Every use of Nix below should be understood to mean using Nix to interact with the nixpkgs set of packages running on macOS. ![]() I have no experience with NixOS (although the idea is neat). In this post, I will not discuss NixOS at all. There are many blog posts by a variety of authors about using Nix, Ian’s series is the most comprehensive (and funny) that I’ve read. Nix is an extremely complex system that is poorly documented. Let me start by acknowledging Ian Henry’s wonderful series of blog posts on Nix. In this post, I’m going to write down how I’m currently using Nix on macOS with the Zsh shell. I recently started using the Nix Package Manager on macOS and the process has been painful.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |