Provisioning a NixOS server from macOS


Setting up Nix and Nix on Darwin (macOS)

$ curl | sh
$ bash <(curl

Setting up a docker build slave

$ docker run --rm -it lnl7/nix nix-repl '<nixpkgs>'
nix-repl> system
$ docker run --restart always --name nix-docker -d -p 3022:22 lnl7/nix:ssh
$ git clone
$ mkdir -p /etc/nix
$ chmod 600 ssh/insecure_rsa
$ cp ssh/insecure_rsa /etc/nix/docker_rsa
Host nix-docker
User root
Port 3022
IdentityFile /etc/nix/docker_rsa
$ sudo ssh nix-docker

Teaching nix about the x86_64-linux build slave

nix.distributedBuilds = true;
nix.buildMachines = [ {
hostName = "nix-docker";
sshUser = "root";
sshKey = "/etc/nix/docker_rsa";
systems = [ "x86_64-linux" ];
maxJobs = 2;
} ];
services.nix-daemon.enable = true;
$ darwin-rebuild switch

Test: building a package for x86_64-linux

$ nix-build -E 'with import <nixpkgs> { system = "x86_64-linux"; }; hello.overrideAttrs (drv: { rebuild = builtins.currentTime; })'


{ webserver = { config, pkgs, lib, ... }:
{ deployment.targetHost = "...";
nixpkgs.system = "x86_64-linux";
$ nixops deploy -d myserver
building all machine configurations...
webserver> copying closure...
myserver> closures copied successfully
webserver> activating the configuration...
webserver> setting up /etc...
webserver> activation finished successfully
myserver> deployment finished successfully




making mobile haskell awesome!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Computing on the Edge or in the Cloud? — Future Technology Blog

Logging to logstash in python from scratch for Windows

WWDC conferences you don’t want to miss

Connect to Azure SQL Server using Python

Safety, Accuracy, Efficiency, then Scale

Configuring Email Server in Jenkins using SMTP gmail

Keeping your customer data in Intercom updated with the Intercom API

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


making mobile haskell awesome!

More from Medium

End-2-End encrypted chat application

Using store with Lit-elements

Hi Gatsby. We’re Jetveo.

How to publish ExDocs on GitHub Pages