<rss version="2.0">
  <channel>
    <title>ivanpollak.com</title>
    <link>https://ivanpollak.com</link>
    <description>ivanpollak.com - Blog</description>
    <generator>Zine -- https://zine-ssg.io</generator>
    <language>en-US</language>
    <lastBuildDate>Wed, 18 Nov 2026 10:25:11 +0000</lastBuildDate>
    
      <item>
        <title>pkgsrc: a slop-free alternative to homebrew</title>
        <description>&lt;p&gt;&lt;a href=&quot;https://www.apple.com/os/macos/&quot;&gt;macOS&lt;/a&gt; is an awesome platform, especially for developers. It is a consumer-friendly &lt;a href=&quot;https://en.wikipedia.org/wiki/Unix-like&quot;&gt;Unix-like&lt;/a&gt; operating system, which makes it pretty similar to most Linux and BSD systems. This especially helps for developing software that is intended to be ran in such an environment. While macOS still has some differences, most software is almost completely &lt;a href=&quot;https://en.wikipedia.org/wiki/Source-code_compatibility&quot;&gt;source-compatible&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Since macOS doesn’t ship with a package manager by default, many third-party projects have been startet to fill this gap, the most popular being &lt;a href=&quot;https://brew.sh&quot;&gt;homebrew&lt;/a&gt;. Because of the source-compatibility with Linux, most packages that can be found in a Linux package manager like &lt;code&gt;apt&lt;/code&gt;, &lt;code&gt;pacman&lt;/code&gt; or &lt;code&gt;apk&lt;/code&gt; cna be found in homebrew.&lt;/p&gt;&lt;p&gt;Homebrew however isn’t without its flaws. It is not very transparent on the source of the &lt;code&gt;.app&lt;/code&gt; files (if it is just a pre-built &lt;code&gt;.app&lt;/code&gt; downloaded from the projects website, for example in the case of &lt;a href=&quot;https://github.com/Homebrew/homebrew-cask/blob/70f02325ff15b873141cc2b0a4b481a87a47a8c7/Casks/f/firefox.rb#L417&quot;&gt;firefox&lt;/a&gt; or if the &lt;code&gt;.app&lt;/code&gt; is actually being built by the package management team. The first being more of a security risk because a malicious actor &lt;em&gt;could&lt;/em&gt; just swap out the binaries and the source code would still look okay), the permissions (brew &lt;em&gt;doesn’t need&lt;/em&gt; &lt;code&gt;sudo&lt;/code&gt; because it basically just changes the permission on the globally installed packages path to be edited by anybody…) but personally my biggest issue is that homebrew &lt;a href=&quot;https://github.com/Homebrew/brew/blob/main/AGENTS.md&quot;&gt;went all-in on LLM’s&lt;/a&gt;. While LLM’s have real world use-cases, the issues with those tools are omnipreent.&lt;/p&gt;&lt;p&gt;This is where &lt;a href=&quot;https://pkgsrc.org&quot;&gt;pkgsrc&lt;/a&gt; comes into play. It presents itself as a “framework for managing third-party software” and after learning and using this “framework” for about three months now, it is possibly one of my favourite pieces of software.&lt;/p&gt;&lt;p&gt;pkgsrc is a project that originates from &lt;a href=&quot;https://netbsd.org&quot;&gt;NetBSD&lt;/a&gt;, an operating system that aims to be “free, fast, secure and highly portable”. The portability is one of the largest focus in this project. The phrase “&lt;a href=&quot;https://www.netbsd.org/about/portability.html&quot;&gt;Of course it runs NetBSD&lt;/a&gt;” is a commonly heard sentence about the project. The operating system currently has releases for 53 different &lt;a href=&quot;https://en.wikipedia.org/wiki/Instruction_set_architecture&quot;&gt;processor architectures&lt;/a&gt; and it even &lt;a href=&quot;https://laughingsquid.com/netbsd-toaster/&quot;&gt;runs on a toaster&lt;/a&gt;!&lt;/p&gt;&lt;p&gt;NetBSD also has a &lt;a href=&quot;https://www.netbsd.org/developers/commit-guidelines.html&quot;&gt;pretty solid stance&lt;/a&gt; on code that was generated by LLM’s: The project prohibits code that was generated by tools such as Copilot or ChatGPT without prior written approval by the core team. This has not happend to this date.&lt;/p&gt;&lt;p&gt;I’m pretty sure that this exeption was made because of security vulnerabilities that are found with the use of LLM’s and affect real world scenarios. LLM’s can be useful for such cases and while I do not support anybody that uses such tools, I see why this is useful and should not be prevented. The NetBSD team also encourages the contributers strongly to understand the code that they’ve written. I believe that this only firther implies that LLM usage will be an exeption rather than the norm.&lt;/p&gt;&lt;p&gt;pkgsrc reflex both previously mentioned philosophies. It is available on various different operating systems such as &lt;em&gt;macOS&lt;/em&gt;, &lt;em&gt;Linux&lt;/em&gt; and of course &lt;em&gt;NetBSD&lt;/em&gt;. It also prohibits the use of LLM’s due to the project being under the NetBSD umbrella.&lt;/p&gt;&lt;p&gt;The framework can be used in two ways: Building everything from source, like for example &lt;code&gt;portage&lt;/code&gt; on gentoo, or by using pre-compiled binary packages like the more commonly used &lt;code&gt;apt-get&lt;/code&gt;, &lt;code&gt;pacman&lt;/code&gt; and &lt;code&gt;apk&lt;/code&gt;. Though the NetBSD project doens’t provide pre-compiled binaries for the macOS platform itself, &lt;a href=&quot;https://mnx.io/&quot;&gt;MNX Cloud&lt;/a&gt; serves those and pkgsrc directly recommends them.&lt;/p&gt;&lt;p&gt;To get started with using the binary packages, head over to the &lt;a href=&quot;https://pkgsrc.smartos.org/install-on-macos/&quot;&gt;official installation guide&lt;/a&gt;. Because this guide is a subject that might change in the future, it is best if I do not explicitly show copy-paste commands in here, however I can explain the general concept of the installer.&lt;/p&gt;&lt;p&gt;First, a tarball is being downloaded and validated that it hasn’t been tampered with, then the tarball will be extracted into &lt;code&gt;/&lt;/code&gt;. This will put some binary files into some path and make those available to the user by adding them to the &lt;code&gt;PATH&lt;/code&gt; variable. At the time of writing this, the path is &lt;code&gt;/opt/pkg&lt;/code&gt;. Lastly it reloads the environment to make the binaries available.&lt;/p&gt;&lt;p&gt;pkgsrc now can be controlled with the high-level cli tool &lt;code&gt;pkgin&lt;/code&gt;. This provides an easy interface to the underlying architecture of pkgsrc to install, update and remove packages on the system. The “underlying architecture” are just the &lt;code&gt;pkg_*&lt;/code&gt; tools, such as &lt;code&gt;pkg_add&lt;/code&gt;. For example, instead of having to write multiple lines of bash to install a package:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;constant operator function&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;constant function&quot;&gt; &lt;/span&gt;&lt;span class=&quot;constant property function&quot;&gt;PKG_PATH&lt;/span&gt;&lt;span class=&quot;constant function&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;string constant function&quot;&gt;&amp;quot;https://cdn.NetBSD.org/pub/pkgsrc/packages&amp;quot;&lt;/span&gt;
&lt;span class=&quot;constant operator function&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;constant function&quot;&gt; &lt;/span&gt;&lt;span class=&quot;constant property function&quot;&gt;PKG_PATH&lt;/span&gt;&lt;span class=&quot;constant function&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;string constant function&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;string constant operator function&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;string constant property function&quot;&gt;PKG_PATH&lt;/span&gt;&lt;span class=&quot;string constant function&quot;&gt;/OPSYS/ARCH/VERSIONS/All/&amp;quot;&lt;/span&gt;
&lt;span class=&quot;constant operator function&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;constant function&quot;&gt; &lt;/span&gt;&lt;span class=&quot;constant property function&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;PKG_PATH&lt;/span&gt;
&lt;span class=&quot;constant operator function&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;constant function&quot;&gt; &lt;/span&gt;&lt;span class=&quot;constant property function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;pkg_add&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;alacritty&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;using &lt;code&gt;pkgin&lt;/code&gt; we only need to write one:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;constant operator function&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;constant function&quot;&gt; &lt;/span&gt;&lt;span class=&quot;constant property function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;pkgin&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;alacritty&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Besides the &lt;code&gt;install&lt;/code&gt; option, the tool also supports:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;upgrade&lt;/code&gt;: Upgrades the installed pacakges and the dependencies that also need to be updated&lt;/li&gt;&lt;li&gt;&lt;code&gt;full-upgrade&lt;/code&gt;: Upgrades all packages on the system&lt;/li&gt;&lt;li&gt;&lt;code&gt;remove&lt;/code&gt;: Removes a package&lt;/li&gt;&lt;li&gt;&lt;code&gt;avail&lt;/code&gt;: List the available packages&lt;/li&gt;&lt;li&gt;&lt;code&gt;search&lt;/code&gt;: Search for a package&lt;/li&gt;&lt;li&gt;&lt;code&gt;autoremove&lt;/code&gt;: Remove orphan dependencies&lt;/li&gt;&lt;li&gt;&lt;code&gt;clean&lt;/code&gt;: Delete packages from the cache directory&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;There are even more options, however this is not a guide about &lt;code&gt;pkgin&lt;/code&gt; but rather pkgsrc, so lets talk about compiling!&lt;/p&gt;&lt;p&gt;As previously mentioned, pkgsrc provides a way to compile everything from the source code. This generally consumes a lot more time and resources, however it can also improve performance. While packages that were pre-compiled may not be optimized, when compiling from source, we can optimize each and every software to our needs. Compiling from source also is considered as being more complex, however pkgsrc is very mature in managing the complexities for the user. The whole three months that I’ve used it so far, I never had an issue with pkgsrc itself but only with the platform around it, in my case macOS.&lt;/p&gt;&lt;p&gt;To start compiling, some prerequisites are needed; Apple’s command line developer tools and a copy of the pkgsrc source tree. If you’ve developed on macOS previously, the first is probably already installed. To test this, simply run &lt;code&gt;xcode-select --install&lt;/code&gt; and if a new window opens, click on “install”, if not, you’re good to go. The latest source tree can either be downloaded from NetBSD’s website as a tarball or from their Github mirror as a git repository. Note that NetBSD (and thus pkgsrc) dont actually use git as their &lt;a href=&quot;https://en.wikipedia.org/wiki/Version_control&quot;&gt;version control&lt;/a&gt;, but rather &lt;a href=&quot;https://en.wikipedia.org/wiki/Concurrent_Versions_System&quot;&gt;CVS&lt;/a&gt;. The github mirror uses a tool to automatically convert from CVS to git, so use this with care. With that being said; I’ve never had issues with the github mirror in the whole time since I started using pkgsrc.&lt;/p&gt;&lt;p&gt;To just test things out, I recommend to just download the tarball from the NetBSD’s project page:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;constant operator function&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;constant function&quot;&gt; &lt;/span&gt;&lt;span class=&quot;constant property function&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;constant operator&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;constant property&quot;&gt;HOME&lt;/span&gt;
&lt;span class=&quot;constant operator function&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;constant function&quot;&gt; &lt;/span&gt;&lt;span class=&quot;constant property function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;-O&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;https://cdn.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.gz&lt;/span&gt;
&lt;span class=&quot;constant operator function&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;constant function&quot;&gt; &lt;/span&gt;&lt;span class=&quot;constant property function&quot;&gt;tar&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;-zxf&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;pkgsrc.tar.gz&lt;/span&gt;
&lt;span class=&quot;constant operator function&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;constant function&quot;&gt; &lt;/span&gt;&lt;span class=&quot;constant property function&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;pkgsrc.tar.gz&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will download and extract the tarball into the users &lt;code&gt;$HOME&lt;/code&gt; directory. It is not that relevant where the pkgsrc repository is located in, however because we’re later on going to install the binaries only for this user, I generally put everything into &lt;code&gt;$HOME&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;Lastly we need to bootstrap some packages which are used by pkgsrc. They are needed for every package and are assumed on each system that pkgsrc is used to build packages. Luckily these can be bootstrapped pretty easily by running a script located in &lt;code&gt;pkgsrc/bootstrap&lt;/code&gt;:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;operator&quot;&gt;$&lt;/span&gt; &lt;span class=&quot;constant function&quot;&gt;./bootstrap&lt;/span&gt; \
	&lt;span class=&quot;constant&quot;&gt;--prefix&lt;/span&gt; &lt;span class=&quot;constant operator&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;constant property&quot;&gt;HOME&lt;/span&gt;&lt;span class=&quot;constant&quot;&gt;/pkg&lt;/span&gt; \
	&lt;span class=&quot;constant&quot;&gt;--prefer-pkgsrc&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;yes&lt;/span&gt; \
	&lt;span class=&quot;constant&quot;&gt;--make-jobs&lt;/span&gt; &lt;span class=&quot;embedded constant&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;embedded constant function&quot;&gt;sysctl&lt;/span&gt;&lt;span class=&quot;embedded&quot;&gt; &lt;/span&gt;&lt;span class=&quot;embedded constant&quot;&gt;-n&lt;/span&gt;&lt;span class=&quot;embedded&quot;&gt; &lt;/span&gt;&lt;span class=&quot;embedded constant&quot;&gt;hw.physicalcpu&lt;/span&gt;&lt;span class=&quot;embedded&quot;&gt;)&lt;/span&gt; \
	&lt;span class=&quot;constant&quot;&gt;--unprivileged&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The script will install, for example, &lt;code&gt;bmake&lt;/code&gt;, BSD’s equivalent of the &lt;code&gt;make&lt;/code&gt; command. This command has some differences to the more common GNU Make and pkgsrc’s package definitions are actually all just Makefiles. This also installs the &lt;code&gt;pkg_*&lt;/code&gt; tools to manage the systems packages. With the flag &lt;code&gt;--prefix&lt;/code&gt; we tell the boostrap script, where pkgsrc should be installed into. This can be any directory that can be written to. pkgsrc even allows for unprivileged installations - so if you do not have superuser privileges on a given computer, you still can build, manage and install software. Afterwards, we tell pkgsrc that all tools should build themself against the pkgsrc provided packages instead of the system ones. For example, macOS shipps perl, m4 and bison. New macOS versions however ship new versions of those tools and it is possible that this will break packages if they would use the binaries that are provided by Apple. The &lt;code&gt;--prefer-pkgsrc&lt;/code&gt; flag tells pkgsrc that we do not want to use those tools but rather rely entirely on pkgsrc for everything. &lt;code&gt;--make-jobs&lt;/code&gt; is used to speed up the build process and lastly the &lt;code&gt;--unprivileged&lt;/code&gt; option tells pkgsrc that we do actually want to setup everything only for this user – in contrast to homebrew this doesn’t tamper with the permissons for a globally accessible directory. Everything that you install will only be available for your user.&lt;/p&gt;&lt;p&gt;Note that on macOS the &lt;code&gt;/$HOME/pkg&lt;/code&gt; is not in the &lt;code&gt;PATH&lt;/code&gt; variable by default, which means that all tools would only be accessible through their absolute path, e.g. by typing in &lt;code&gt;/$HOME/pkg/bin/...&lt;/code&gt;. To fix this, run the following commands. They will add the needed directories to the &lt;code&gt;PATH&lt;/code&gt; variable and then update the shell.&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;constant operator function&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;constant function&quot;&gt; &lt;/span&gt;&lt;span class=&quot;constant property function&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;string constant&quot;&gt;&amp;apos;export PATH=&amp;quot;/Users/&amp;lt;username&amp;gt;/pkg/bin:/Users/&amp;lt;username&amp;gt;/pkg/sbin:${PATH}&amp;quot;&amp;apos;&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;property&quot;&gt;HOME&lt;/span&gt;/.zshrc
&lt;span class=&quot;constant operator function&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;constant function&quot;&gt; &lt;/span&gt;&lt;span class=&quot;constant property function&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;string constant&quot;&gt;&amp;apos;export MANPATH=&amp;quot;/Users/&amp;lt;username&amp;gt;/pkg/man:${MANPATH}&amp;quot;&amp;apos;&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;property&quot;&gt;HOME&lt;/span&gt;/.zshrc
&lt;span class=&quot;constant operator function&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;constant function&quot;&gt; &lt;/span&gt;&lt;span class=&quot;constant property function&quot;&gt;source&lt;/span&gt; &lt;span class=&quot;constant operator&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;constant property&quot;&gt;HOME&lt;/span&gt;&lt;span class=&quot;constant&quot;&gt;/.zshrc&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After all of this, we now finally can compile our first package. To keep things simple, lets compile &lt;em&gt;GNU Stow&lt;/em&gt;, a dotfiles/symlink management tool. pkgsrc is seperated into different directories based on the software’s category. For example, there is the audio category, which contains the build script for &lt;em&gt;ardour&lt;/em&gt;, there is the www category, which contains the build script for &lt;em&gt;firefox&lt;/em&gt; and for us, the sysutils category is of special interest, because it contains the build script for stow. So lets go in there with:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;constant operator function&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;constant function&quot;&gt; &lt;/span&gt;&lt;span class=&quot;constant property function&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;sysutils/stow&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;All that is left to do is to build the software. This can be done with &lt;code&gt;bmake&lt;/code&gt; but behold, there is more behind this than one might think. pkgsrc builds upon the concept of “What if software was standardized and there was no need for different build systems. One should simply be able to go into the softwares repository and type &lt;code&gt;make&lt;/code&gt; to build the software.” This can be done using pkgsrc. Commonly used options like &lt;code&gt;install&lt;/code&gt; or &lt;code&gt;clean&lt;/code&gt; are also available for every package and they do exactly what one might expect. So with that knowledge, lets build the package:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;constant operator function&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;constant function&quot;&gt; &lt;/span&gt;&lt;span class=&quot;constant property function&quot;&gt;bmake&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;clean-depends&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;clean&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will build the package, install it, then clean up the dependencies files and lastly clean up the packages files. To check if stow is installed, use &lt;code&gt;stow --version&lt;/code&gt;, which in my case returns &lt;code&gt;stow (GNU Stow) version 2.4.1&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;However most users may not use stow and thus do not want this software installed. So lets see how to uninstall software in pkgsrc. First we can take use &lt;code&gt;pkg_info&lt;/code&gt; to get further information about the stow package:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;constant operator function&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;constant function&quot;&gt; &lt;/span&gt;&lt;span class=&quot;constant property function&quot;&gt;pkg_info&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;stow&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If this command doesn’t fail, it is confirmed, that this package is installed on the system. Now lets uninstall it using:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;constant operator function&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;constant function&quot;&gt; &lt;/span&gt;&lt;span class=&quot;constant property function&quot;&gt;pkg_delete&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;stow&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This now should have successfully uninstalled stow from the system. To check this, run &lt;code&gt;pkg_info stow&lt;/code&gt; again. This should now return something like &lt;code&gt;pkg_info: can&amp;apos;t find package &amp;apos;stow&amp;apos;&lt;/code&gt;. This confirms that stow was successfully uninstalled from the system.&lt;/p&gt;&lt;p&gt;With the basics covered, lets explore the configuration of pkgsrc a bit more. The main configuration file for the framework happens in the &lt;code&gt;mk.conf&lt;/code&gt; file, which is located in &lt;code&gt;$HOME/pkg/etc&lt;/code&gt;. This file will already exist if pkgsrc is installed correctly, so there is no need to &lt;code&gt;touch&lt;/code&gt; it. Lets take a look at the default &lt;code&gt;mk.conf&lt;/code&gt;:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;.ifdef BSD_PKG_MK

PKGSRC_COMPILER= clang
CC= clang
CXX= clang++
CPP= ${CC} -E
CLANGBASE= /usr

UNPRIVILEGED= yes
PKG_DBDIR= /Users/test/pkg/pkgdb
LOCALBASE= /Users/test/pkg
SYSCONFBASE= /Users/test/pkg/etc
VARBASE= /Users/test/pkg/var
PKG_TOOLS_BIN= /Users/test/pkg/sbin
PKGINFODIR= info
PKGMANDIR= man

PREFER_PKGSRC= yes

TOOLS_PLATFORM.sh?= /Users/test/pkg/bin/mksh
TOOLS_PLATFORM.awk?= /Users/test/pkg/bin/nawk
TOOLS_PLATFORM.sed?= /Users/test/pkg/bin/nbsed

.endif
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The first few lines will set the correct c compiler which, in the case of macOS, is &lt;code&gt;clang&lt;/code&gt;. &lt;code&gt;clang&lt;/code&gt; comes with the previously installed command line developer tools, directly from Apple. Afterwards some variables are set for the correct prefixes of installed files. This might seem weird, because everything is just located under &lt;code&gt;/User/test/pkg&lt;/code&gt;, however it can be really useful if, for example, the configuration (&lt;code&gt;/etc&lt;/code&gt;) files live on an network filesystem and not on the actual system. This is the same with the other variables, so for example, databases (commonly located under &lt;code&gt;/var&lt;/code&gt;) also can live under other locations than under the pkgsrc installation path.&lt;/p&gt;&lt;p&gt;Next, we prefer pkgsrc’s tools. The reason on why to do this is previously mentioned.&lt;/p&gt;&lt;p&gt;And lastly the installation path of the tools that pkgsrc uses are defined. This is done because some tools are different under different platforms, just like GNU Make and NetBSD’s Make. For example, macOS doesn’t use GNU sed and thus some configure scripts don’t work as expected if the default sed is used. With these variables set, installation scripts and alike from pkgsrc’s packages wont complain about some extension not being available.&lt;/p&gt;&lt;p&gt;This configuration script is pretty simple but works perfectly, however on most macOS systems some further configuration is wanted. Some additional settings that I’ve added to my configuraton include:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;MAKE_JOBS= 10
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This will tell &lt;code&gt;make&lt;/code&gt; to use all the available cores on my system to build an application. By default it is set to &lt;code&gt;1&lt;/code&gt; so setting this will improve compilation times by quite a bit. Note that your system may have more or less cores available. To find out your core count, use &lt;code&gt;sysctl -n hw.physicalcpu&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;I would also like to mention that pkgsrc can be configured to only install packages under certain licenses. This can be useful if a company doesn’t develop something that will be open source. It therefore only can use packages under some non-gpl license. This can be set using the &lt;code&gt;ACCEPTABLE_LICENSES&lt;/code&gt; variable.&lt;/p&gt;&lt;p&gt;There are many many more possible options that can be adjusted and a list of  all default variables can be found under &lt;a href=&quot;https://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/mk/defaults/mk.conf&quot;&gt;pkgsrc/mk/defaults/mk.conf&lt;/a&gt;. Most of the variables have some sane defaults, however if wanted, pkgsrc can be customized pretty heavily.&lt;/p&gt;&lt;p&gt;To find out more about this awesome package manager, head over to &lt;a href=&quot;https://pkgsrc.org&quot;&gt;pkgsrc.org&lt;/a&gt;, where you can find an &lt;a href=&quot;https://www.netbsd.org/docs/pkgsrc/&quot;&gt;extensive documentation&lt;/a&gt; for this software. Additionally if some help is needed either send an email to the &lt;a href=&quot;mailto:pkgsrc-users@NetBSD.org&quot;&gt;official pkgsrc-users mailing list&lt;/a&gt; or send some message into the &lt;code&gt;#pkgsrc&lt;/code&gt; &lt;a href=&quot;https://en.wikipedia.org/wiki/IRC&quot;&gt;IRC channel&lt;/a&gt; on the libera network.&lt;/p&gt;</description>
        <link>https://ivanpollak.com/blog/pkgsrc_a_slop_free_alternative_to_homebrew/</link>
        <pubDate>Mon, 26 Oct 2026 00:00:00 +0000</pubDate>
        <guid>https://ivanpollak.com/blog/pkgsrc_a_slop_free_alternative_to_homebrew/</guid>
      </item>
    
  </channel>
</rss>
