An easy to use Linux builder for macOS [maintainer=@nicknovitski]
Go to file
Badi Abdul-Wahid 083e65f592
dont store socket files in the nix store
Using the nix store to store the state files causes problems when
restarting the guest because socket file types not supported by nix
2020-05-04 11:11:52 -05:00
go-vpnkit go-vpnkit: 0.2.0 -> 0.3.0 (#25) 2019-07-22 17:24:40 -07:00
hyperkit hyperkit: set VERSION_SHA1 to rev 2019-07-30 11:27:12 -07:00
linuxkit linuxkit: 0.2 -> 0.6 2019-07-22 17:22:49 -07:00
linuxkit-builder dont store socket files in the nix store 2020-05-04 11:11:52 -05:00
nix-linuxkit-runner nix-linuxkit-runner: add the missing Security.framework (#19) 2018-11-07 19:13:09 +01:00
nix-script-store-plugin nix-script-store-plugin: move into own folder 2018-11-07 17:26:43 +01:00
virtsock Initial commit 2018-04-02 05:57:18 -07:00
vpnkit Initial commit 2018-04-02 05:57:18 -07:00
.gitignore Initial commit 2018-04-02 05:57:18 -07:00
COPYING Add license 2018-04-03 14:06:35 -07:00
default.nix Reimport properly 2018-07-07 11:48:56 -04:00
example.nix Port the work from nixpkgs 2018-04-10 14:55:20 -04:00
overlay.nix nix-script-store-plugin: use clang 6.x (#27) 2019-07-22 17:22:49 -07:00
README.md Document how to uninstall 2020-01-14 10:08:08 -08:00
release.nix remove nix from release.nix 2018-11-07 17:26:45 +01:00

LinuxKit Nix - Linux on Mac Nix builder

hydra jobset

LinuxKit Nix makes it easy to build Linux binaries from a macOS machine using Nix. It's installing a VM using the native virtualization (Hypervisor.Framework) so it's quite liteweight compared to installing VirtualBox. The project also comes with an installation script that configures Nix to use the VM as a remote builder automatically.

Requirements

This project depends on Nix and a nixpkgs channel >= 18.03.

Installation

Fetch it from the NixOS binary cache:

nix-env -i /nix/store/jgq3savsyyrpsxvjlrz41nx09z7r0lch-linuxkit-builder
nix-linuxkit-configure

It'll write to:

  • ~/.cache/nix-linuxkit-builder/, in particular ~/.cache/nix-linuxkit-builder/nix-state/console-ring is interesting
  • ~root/.ssh/ for the SSH config
  • /etc/nix/machines
  • ~/Library/LaunchAgents/org.nix-community.linuxkit-builder.plist

Once installed the daemon should automatically start and stay running.

Debugging

To see if the daemon is running execute the following command and look at the first column. If it has a number (PID) it's running, if it's - then it's stopped:

launchctl list | grep linuxkit

You can force start it with:

launchctl start org.nix-community.linuxkit-builder

You can force stop it with:

launchctl stop org.nix-community.linuxkit-builder

If after you stop it you may want to check for processes, like:

pgrep vpnkit
pgrep linuxkit
pgrep hyperkit

If something goes wrong and it didn't stop properly, you can try:

pkill -F ~/.cache/nix-linuxkit-builder/nix-state/hyperkit.pid hyperkit

Troubleshooting

cannot build on 'ssh://nix-linuxkit': cannot connect to 'nix-linuxkit' ...

When runninng nix-linuxkit-configure, an SSH config is created at /var/root/.ssh/nix-linuxkit-ssh-config. Copy the contents of that SSH config into your regular SSH config located at ~/.ssh/config.

error: 'x86_64-linux' is require to build ...

Check the /etc/nix/nix.conf file for a builders option. It should either be set to @/etc/nix/machines or not set at all for LinuxKit Nix to work properly.

Another solution is to set export NIX_REMOTE_SYSTEMS=/etc/nix/machines before running the nix or nixops command.

cannot build on 'ssh://nix-linuxkit': cannot connect ...: Operation timed out

Something is wrong with LinuxKit. See the debugging section to try things out.

Leave an issue at https://github.com/nix-community/linuxkit-nix/issues

Uninstalling

# Remove configuration
rm -rf ~/.cache/nix-linuxkit-builder/

# Remove build machine
# (edit manually if you have other configuration here)
sudo rm -f /etc/nix/machines

# Remove LaunchAgent
launchctl stop org.nix-community.linuxkit-builder
rm -f ~/Library/LaunchAgents/org.nix-community.linuxkit-builder.plist

# Remove SSH config
# (edit manually if you have other configuration here)
sudo rm -rf /var/root/.ssh

# Uninstall Nix package
nix-env -e linuxkit-builder