顺便说一句,我用过 Arch:macOS,第一天。
I Used Arch, BTW: macOS, Day 1

原始链接: https://yberreby.com/posts/i-used-arch-btw-macos-day-1/

## 从 Arch 到 Apple:一次相对顺利的过渡 一位研究人员在各种笔记本电脑上持续使用 Arch Linux 九年后,由于 PC 笔记本电脑持续存在的硬件问题,转而使用新的 M4 Pro MacBook Pro。虽然对 Arch 的定制性和控制力非常满意,但不断需要解决驱动程序问题和修复故障硬件却让人感到疲惫。 目标并非完全复制 Arch,而是要在 macOS 上重建一个高效的工作流程。这包括利用 Zed(一个基于 Vim 的编辑器)、Zotero 进行研究,以及采用 shell 为中心的方法。关键在于找到 macOS 中 Linux 实用程序的等效替代品,以及一个强大的包管理器。 尽管 Nix 具有一定的复杂性,但它提供了一种声明式的方法,因此被选为包管理器。初始设置需要进行故障排除(调整状态版本、解决构建错误),但最终可以安装核心工具,如 Alacritty、Raycast(用于窗口管理)和 AeroSpace(一个平铺窗口管理器)。 虽然并非完美,但由此产生的“懒人 Frankenstein Mac”提供了一个可用的环境,让研究人员能够专注于他们的工作——神经人工智能博士研究——而不是与硬件作斗争。初步印象是积极的,赞赏 MacBook Pro 的制造质量和响应速度,即使需要借助第三方工具才能实现熟悉的工作流程。

一个 Hacker News 的讨论围绕着 macOS 上的软件包管理,起因是一位用户从 Arch Linux 切换到 macOS。最初的帖子表达了对软件包管理更强控制的渴望,让人联想到 Arch 的 `pacman`。 对话很快集中在 macOS 流行的软件包管理器 Homebrew 上。一些用户报告了持续的积极体验,而另一些用户则描述了更新时频繁出现问题以及涉及大量软件包的漫长更新过程。人们对 Homebrew 的文件系统权限表示担忧。 Nix 也被提及作为一种替代方案,但即使安装程序有所改进,也被描述为在 macOS 上“糟糕透顶”。原发帖者正在探索 Nix 以恢复软件包管理的纪律性,承认 Nix 在 macOS 上是非官方支持,并且由于硬件兼容性存在限制。最终,该帖子展示了一种常见的沮丧:macOS 上的软件包管理不如一些用户期望的那么流畅或可靠。
相关文章

原文

TL;DR: I used Arch Linux for nine years as a daily driver on non-Apple laptops. I received my new M4 Pro MacBook Pro yesterday. This recounts my experience configuring it to hit the ground running from day 1.

If you're a Linux user making the switch to Apple Silicon, or thinking of doing so, this post may be of interest.

Zed, AeroSpace, Raycast's "Switch Windows" and Alacritty in action.

What I Need My Computer For

The way one uses their computer is shaped by their needs, values, and habits.

As of writing, I am midway through my PhD at McGill University and Mila, focusing on neuro-AI research at McGill's Department of Physiology. My background is in computer engineering.

My workflow as a PhD student involves a mix of:

  • Filing, reading and annotating scientific papers using Zotero;
  • Writing code in Zed, a fast text editor with first-class support for LSP and Tree-Sitter, GPU acceleration, Rust-powered multithreading, and, non-negotiably, vim bindings;
  • Doing most of my computer interaction inside of a zsh shell with a featureful prompt such as Starship (previously, grml-zsh-config or oh-my-zsh);
  • Managing Python projects using Astral's uv;
  • Writing bespoke command-line utilities in Rust;
  • Using JAX and PyTorch for numerical simulations and deep (reinforcement) learning;
  • Doing exploratory development using local Jupyter Lab notebooks;
  • Firing off longer-running jobs on remote compute resources, using on-premises workstations or larger SLURM clusters;
  • Writing down notes in my org-roam personal knowledge base;
  • Writing papers and slides in Typst or LaTeX (if I have to);
  • Collaborating with colleagues on Zulip, Slack, or in person;
  • Attending scientific meetings in-person or virtually (and taking live notes in org-roam);
  • Staring intensely at a whiteboard/wall/ceiling when I'm mulling over a problem (no tech required);
  • Debugging anything and everything: driver issues on compute workstations, sub-millisecond timing code in psychophysics experiments using custom Teensy photodiode contraptions, shared object loading in proprietary camera software, etc.
  • Writing blog posts such as this one using a static site generator, Zola.

Depending on the needs of the hour, I'll put on my researcher, engineer, sysadmin, or communicator hat, and I need my computing environment to support this workflow.

Nine Beautiful Years of Arch Linux

I didn't start out on Linux. I digitally grew up on System 7, Mac OS 9, then Mac OS X, in an Apple-centric household where "Windows" was a profanity. While the UNIX backbone of Mac OS X made it a great introduction to computing, I eventually grew frustrated with the developer experience, exorbitant repair costs (what do you mean, everything is glued or soldered?), lackluster GPU performance, and poor support for projects I wanted to hack on. As a result, I switched to Arch Linux in 2016 after briefly trying Debian, Ubuntu, and Fedora. Since then, I've faithfully used Arch as my daily driver on various machines: a trusty Asus Zenbook UX410U, two self-built desktop workstations, numerous VirtualBox VMs, two Tuxedo Pulse 15 laptops from Tuxedo Computers, an Asus TUF A15, and others. After a couple of early reinstalls, I mostly migrated systems via SSD swaps or dd clones.

From day one, I embraced the Arch spirit, consistently running either i3 or sway as my tiling window managers of choice, complete with a panel of shortcuts allowing me to get much of my computer use done at the speed of thought. I'm proud to say that over the years, a number of friends and coworkers adopted similar setups after seeing how fast one's computer use could get, in search of a streamlined yet ruthlessly efficient system configuration.

Arch is a stellar distro. The package management story is top-notch. Packages are up-to-date, easy to create and maintain, and come close to the upstream sources without distro-specific patches. pacman just works, and the AUR gives you access to the most obscure of packages. The documentation on the Arch Wiki is excellent, to the point that it's often worth checking when troubleshooting a problem on another distro. On Arch, you build your system piece by piece, trading initial setup time for deep understanding. This is both intellectually satisfying and practically empowering.

Given how freeing the Arch experience is, it has been difficult for me to imagine using anything else. Occasionally having to use a Mac or Windows PC seemed like a test of patience; Arch felt like home. A computing environment that I trust, that I understand, built by and for me, sculpted according to my precise needs, changing by my will and not due to some tech company's idea of what's good for me ("hey, it's 2025, we should make everything unreadable!").

So... what's the catch, then? Why migrate away from something so good?

Hardware That Wears You Out

While Arch Linux itself, as a Linux distribution, is great, it needs to run on something. And when it comes to laptops, that something is not great.

PC laptops are mostly not built for Linux. This means that any laptop purchase has historically come with a series of driver-related caveats. Will suspend-to-RAM work? Will I get more than a few hours of battery life after installing TLP? Do the GPU drivers work at all, including with PRIME/Optimus switching? Will my Wi-Fi chipset randomly disconnect from WPA2 Enterprise networks or cause kernel panics? Can I use any of the "fancy" manufacturer features, such as a fingerprint reader, or are they locked behind proprietary drivers that only support Windows? Will my Bluetooth randomly disconnect and reconnect, or drop packets excessively?

Most of these issues are not a concern on desktop workstation or server hardware, and indeed, I wouldn't run anything but Linux on those. However, on a laptop, having to take all of these into account is exhausting. I want to use my laptop to tackle problems, not to have my laptop be the problem.

Driver issues aren't all there is. Anecdotally, I've recently been dealing with a series of catastrophic hardware failures: busted laptop hinges and screw mounts, random boot failures, spotty Bluetooth, trackpad glitches, and more, across my last few devices. Recently, two of my laptops kernel panicked from being held wrong, and the latest one (an Asus TUF A15) pops open like a piñata when opened without several layers of super-strength tape holding the case together. This machine is not even a year old.

Of course, similar issues can and do occur on MacBooks as well, and my sample size is statistically insignificant. However, I don't think it is too much to ask for 1) warranties that are actually honored, and 2) hardware that amounts to more than a haphazardly assembled pile of fast components.

Could a Dell XPS, Lenovo ThinkPad, Surface Pro, TUXEDO or Framework Laptop fit the bill? Probably, depending on the compromises one is willing to make.

However, I decided to give Apple Silicon a chance this time around. This was partly curiosity—Apple laptops are known for their build quality, battery life, unified memory, and customer service. I had also briefly used a M1 MacBook Air out of necessity, while working on cross-compilation of OCaml code to iOS at Routine, and came out quite impressed with the smoothness of the UX on this relatively cheap machine.

Tired of fighting my hardware, I opted to fight "my" (Apple's, really) software this time around, trading my meticulously-honed setup for the foreign and locked-down macOS.

Eating the Forbidden Fruit

When I caved in and bought a custom 14" 48GB M4 Pro MacBook Pro with the intent of keeping macOS on it, reactions ranged from confusion ("this guy bought a Mac?!") to glee ("how the mighty have fallen!") to disappointment ("you should have bought a Framework") to concern ("are you sure you're OK?"). The general sentiment was whathehellishappening? 🎶.

Would running Linux on it be an option? No. Asahi Linux only delivers good support up until M2 chips, with M4 Pro support remaining entirely inadequate. So, macOS it is. Quite frankly, I probably still wouldn't try running Linux on it even if there were some Asahi support. If I'm going to be using Mac hardware, I might as well take full advantage of it.

The Lazy Frankenmac

Running macOS does not mean giving up on the past decade of accumulated experience. I live inside of a shell. I want my configuration to be as declarative as possible. A good tiling window manager is non-negotiable. I want my window switching to be nearly instantaneous, and I am not about to start preferring the mouse/touchpad over the keyboard.

I received my new machine yesterday, and opted to set it up the "lazy power user" way: I wanted to recover as much of my workflow as possible, without going down a rabbit hole of configuration. Not all battles are worth fighting. It is a delicate balance between "I don't have time to configure this, I have urgent things to do" and "I am now taking three times as long to do anything because my SSH agent doesn't work, my most-frequently-used shortcuts are gone, and I manage my packages with ./configure && make && make install."

I will live without my terminal's colors being configured just right for now, as long as they're reasonable. Same with my shell prompt; if it has a decent git indicator and autocompletion, that's a good start. There is something freeing in embracing sane defaults, then gradually improving them.

Let's call this a "Lazy Frankenmac"—not in the Hackintosh sense, but in the sense that it's macOS set up in a Linux spirit.

What key ingredients would that involve?

  • A sensible package and configuration management story.
  • A modern shell environment.
  • A tiling window manager, in the spirit of i3 / sway / hyprland.
  • A launcher in the spirit of dmenu / rofi / wofi.

We're not going to get everything right in a day, far from it, but let's see how far we can get.

Nix as a Package Manager

First, let's get our package manager set up. Installing software by dragging and dropping .app files or running installers manually is... not ideal, and neither is the locked-down Mac App Store.

The macOS package management story is not great. There's no good built-in solution. Homebrew is by far the most popular package manager, widely used by developers. MacPorts is older but less popular. Neither is really comparable to Arch's pacman.

There's something more exotic than Homebrew and MacPorts to try: you can run Nix on macOS. nix-darwin does the legwork and nix-homebrew serves as a convenient escape hatch for when you need Homebrew Casks or when the Nix package you need is missing or outdated.

Nix is conceptually appealing (purely functional, declarative package and configuration management, yay!), but can be quite difficult to troubleshoot. I've used it a few times in limited contexts, but never as my primary package manager. Thankfully, there's a popular starter template that puts together nix-darwin, nix-homebrew and various other goodies to quickly get started with Nix on macOS!

Of Course It Doesn't Work Out of The Box

Following @dustinlyons's instructions as of commit da88287, I installed Nix using the Determinate Systems installer. This is not to be confused with installing Determinate Nix using that very same installer. Rookie mistake! Definitely not a footgun.

I then did not add experimental-features = nix-command flakes to /etc/nix/nix.conf during setup. Those were already in extra-experimental-features.

I followed the starter-with-secrets template:

mkdir -p nixos-config
cd nixos-config
nix flake \
    --extra-experimental-features 'nix-command flakes' \
    init \
    -t github:dustinlyons/nixos-config#starter-with-secrets

That --extra-experimental-features flag, as specified by the template's README, was probably not necessary since it was already in nix.conf.

My MBP is running macOS Sequoia 15.5. This is a fresh install, so I shouldn't have to "prepare Nix" for a Sequoia installation. Yet, the installation failed at first, with a mismatching GID error. Changing stateVersion = 4; to stateVersion = 5; in hosts/darwin/default.nix resolved the issue.

I then encountered more issues.

  • test-fs-cp.mjs failed when trying to build nodejs-22.17.0. I don't need this LTS Node.js version anyway, so I replaced the nodejs package with nodejs_24 and removed the corresponding nodePackages entries from the relevant packages.nix config.
  • The alacritty configuration included in the template was obsolete, resulting in a number of unused config key warnings.
  • I had an issue with the masApps key, which included entries for 1password and wireguard. I discarded these, as I need neither.
  • The Dock configuration was slightly broken out-of-the-box, but easy to adjust.
  • The bundled Emacs configuration seems broken, with Emacs freezing on startup.

Additionally, installing the AeroSpace tiling WM as a Cask required adding an entry to flake.nix's inputs:

homebrew-aerospace = {
  url = "github:nikitabobko/homebrew-tap";
  flake = false;
};

Once Nix is Set Up, You're Flying

Once I got nix run .#build-switch to work well enough, it was a breeze to install a number of tools as a combination of nix-homebrew Casks, Nix packages, and home-manager entries.

In no particular order, these include: Zed, Zotero, Firefox, Spotify, Proton Mail, Proton Mail Bridge, claude-code, rustup, uv, zola, typst, Signal, WhatsApp Web, Slack, Alacritty, KeePassXC, Raycast, Claude Desktop, and Zulip. I did install Tailscale through its official .pkg installer; it needs a lot of low-level system access, and debugging the macOS networking stack is not my top priority at the moment.

Key features are OK:

Window Management: For now, AeroSpace + Raycast are a very acceptable replacement for sway + rofi/wofi. Following the official AeroSpace recommendation, I disabled the Displays have separate Spaces macOS feature. I have been enjoying Raycast's hotkeys and aliases so far; no skhd required (yet?).

Text Editing: I quickly remapped Caps Lock to Escape and set Zed to use vim bindings. @dustinlyons's starter template includes a reasonable configuration for vim itself.

Python and Rust: uv works, and I'm able to build Rust projects with dependencies on e.g. openssl using direnv's use flake and a lightweight flake.nix.

Browser: Firefox. Not much to say here. I only needed two Firefox extensions from the get-go: Zotero Connector to save papers, uBlock Origin to get rid of ads. I could probably even have done without the latter, given Firefox's new built-in privacy features.

Shell: The zsh configuration included in the template is a decent start. I added atuin through home-manager, for featureful Ctrl+R shell history search.

Terminal Emulator: Currently using alacritty. Also considering WezTerm.

Closing Words

This is how far I got on the first day. This setup isn't perfect, but it's usable; I can perform most of my workflow without pulling my hair out. I'll be honing the system gradually. This includes slimming down and modernizing my nixos-config, understanding Nix beyond the surface level, mastering AeroSpace and Raycast, and fixing various little annoyances as they pop up.

I'm surprised by how much I like this machine already. It is great to look at, hold, and type on. The trackpad is top-notch. Using it generally feels snappy. The built-in software gives the general impression of having been designed, not cobbled together. It remains to be seen how these initial impressions will hold up over time, and it is certainly a shame that one has to resort to third-party tools for something as fundamental as package management. But I suppose I can live with it in exchange for a machine that doesn't kernel panic when I open the lid at the wrong angle.

联系我们 contact @ memedata.com