When comparing pkgsrc vs Nix package manager, the Slant community recommends Nix package manager for most people. In the question“What are the best Mac package managers?” Nix package manager is ranked 2nd while pkgsrc is ranked 5th. The most important reason people chose Nix package manager is:
Every time your profile changes, you get a new generation of your profile and older generations are kept around, so you can easily (and atomically) revert to older version of your profile.
Specs
Ranked in these QuestionsQuestion Ranking
Pros
Pro pkgin is an apt-like tools for installing binaries from pkgsrc
pkgin aims to be a tool similar to apt/yum for managing pkgsrc binaries by relying on pkg_summary for installing, removing and upgrading packages and dependencies, using a remote repo.
Pro Adapted for use on over a dozen different operating systems
Has been adopted to be used on several Unix-like operating systems and Windows. It's also the default package manager of DragonflyBSD and of the (now discounted) Bluewall Linux distro.
Pro Installs and works in the same way as MacPorts
Installs its own dependencies which means that it is very secure. Cannot install anything unless you use the "sudo" command which is in keeping with the Unix philosophy.
Pro Both binary packages and source build possible
Fast software installation is possible by using binary packages. It's also easy to build from source which allows for different compile-time options (like different UI backends) as well as gaining access to pre-release versions of software in certain cases.
Pro Offering tooling for backporting fixes
Backporting fixes can be done by cherry-picking updates from a newer branch (pkgsrc is released every 3 months) and creating a package. Sometimes bugs need to be fixed for production and there is neither a fix in newer pkgsrc nor the softwares upstream. So pkgsrc has tools like pkgdiff, mkpatches, etc. that help with developing patches and building binary packages from that. A bit of documentation about that process can be found here.
Pro Does not need Xcode command line tools or Xcode.
This means that you can install it fresh on a new installation of MacOS and have all your favorite apps installed right from the start.
Pro Works easily with Ansible
Can be used from within Ansible to install packages on macOS.
Pro Easy installation if you use 3rd party scripts
This one works brilliantly.
Pro It's easy to revert any change in your environment
Every time your profile changes, you get a new generation of your profile and older generations are kept around, so you can easily (and atomically) revert to older version of your profile.
Pro Packages installed with Nix don't overlap with packages installed in /usr/local
Since packages are stored in the /nix directory, it won't overlap with anything you'd install in /usr/local or wherever else.
Pro Can keep around several profiles for you to use
You can have different (probably overlapping) sets of software installed in two or more profiles that will be handled (changed, versioned, upgraded, reverted) independently. All software will be installed in the same /nix/store, so any overlaps between your sets will be physically installed only once.
Pro You always and atomically get an isolated consistent profile
Every time you install, delete or change anything you get a new fresh copy of your user environment (set of symlinks to files in /nix/store) that's stored in the same /nix/store and handled mostly the same way. Your "profile" (symlink to one of environments) is updated after everything else is ready, so you'll never end up in a half-finished state of your system.
Pro Does not require root priviledges
Everything is owned by your user (unless you use more powerful multiuser mode that doesn't require root either).
Pro Uses binary caches (that are provided) so you don't have to build anything locally
Due to its functional nature, it can just download a binary package with the same hash if its available and it'll get the very same package as you'd build locally (to the last bit that is).
Pro Packages don't change after they are built
Nix treats packages like values in a functional language. Since they are built by functions without side effects they never change after they are built.
Pro Very easy to share compiled binaries between machines
You can share packages via HTTP or SSH (push or pull) with just some simple commands.
Pro Easy to install
Requires just one shell script to install, only one directory is created via sudo. This makes for a pretty simple install method that most can grasp.
Pro Many apps
Since it is compatible on Mac and Linux, there are many apps in their repos.
Cons
Con Not so broadly used on MacOS as compared with MacPorts
You do not hear about Pkgsrc as openly as you hear the words "HomeBrew" or "MacPorts".
Con Outdated packages
Some packages are outdated.
Con Can't install some packages
Even building well known packages (except MacPorts) from source using the ports can fail.
Con Relatively complicated setup and installation
Installing and setting pkgsrc up is a bit more complicated than in other package managers where it often consists in running a single script.
Con Steep learning curve
There are lots of unfamiliar concepts and jargon (e.g. fixpoint, instantiate, realise).
Con Cannot handle filetypes that have different semantics across different versions
While the functional approach that Nix takes is great for sandboxing binary artifacts of packages, it seriously lacks any power in handling configuration files or user data. It's difficult to upgrade and downgrade files where semantics and syntax can change between versions. Especially in Debian/Ubuntu it can cause severe problems where the upgrade process blocks and the user needs to resolve the 3-way merge.
