Marshall Bowers

Conjurer of code. Devourer of art. Pursuer of æsthetics.

WorkOS and NixOS

Sunday, November 8, 2020
521 words
3 minute read

Greetings, travelers.

It's been some time since I last wrote one of these. The past few months have been rather difficult for me, which ultimately led to my radio silence, but I'm happy to report that things are looking up.

Joining WorkOS

This past week was my first week as a software engineer at WorkOS. I couldn't be any more excited about joining the team here, and I already feel like I'm starting to settle in.

Nix on macOS

As part of setting up my new work machine, I started delving into using Nix on macOS. I was a little apprehensive going into this, as using Nix on macOS—especially Catalina—is reportedly problematic. I'm not one to let rough edges stand in my way, so I decided to give it a try.

Thankfully, the aforementioned issues with Nix on Catalina have been partially addressed as of Nix 2.3.8. To install Nix on macOS, you can pass the --darwin-use-unencrypted-nix-store-volume flag to the install script, as suggested by the docs:

sh <(curl https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume

I initially had some trouble with this, as running the script seemed to do nothing. After a bit of debugging, I realized that https://nixos.org/nix/install is actually just a redirect to the install script for the latest version of Nix. Currently, it redirects to https://releases.nixos.org/nix/nix-2.3.8/install.

I figured curl must not like resolving the redirect, so I subbed in the resolved link and the installation went down without a hitch:

sh <(curl https://releases.nixos.org/nix/nix-2.3.8/install) --darwin-use-unencrypted-nix-store-volume

Once Nix was installed I went about installing Home Manager, which is my preferred way of managing my program and dotfiles:

nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --update

nix-shell '<home-manager>' -A install

I'm a fish user, and in order to get fish to recognize my Nix environment on startup I had to add the following to my Nix-managed fish initialization script:

set -p fish_function_path ${pkgs.fish-foreign-env}/share/fish-foreign-env/functions
fenv source ${config.home.profileDirectory}/etc/profile.d/nix.sh > /dev/null
set -e fish_function_path[1]

This sources the ~/etc/profile.d/nix.sh file using fenv, which saved me from having to port the entirety of nix.sh by hand to fish.

I'm still in the process of setting everything up, but my dotfiles are available on GitHub if you would like to check them out.

At some point I also plan to look into nix-darwin as a way to manage more of my Mac's configuration through Nix.

If anyone else has had any success (or lack thereof) running Nix on macOS, I'd love to hear from you.

Until next time,

Marshall