From 30b53c8f72db7da42fbbdb862460228f803afb83 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Thu, 22 Feb 2024 13:55:43 -0500 Subject: [PATCH] darwin: add linux builder --- flake.lock | 11 ++++++----- flake.nix | 4 +++- systems/darwin/ci.nix | 29 +++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 systems/darwin/ci.nix diff --git a/flake.lock b/flake.lock index fb531171..fa09a5cf 100644 --- a/flake.lock +++ b/flake.lock @@ -914,15 +914,16 @@ ] }, "locked": { - "lastModified": 1708231718, - "narHash": "sha256-IZdieFWvhBkxoOFMDejqLUYqD94WN6k0YSpw0DFy+4g=", - "owner": "lnl7", + "lastModified": 1708541070, + "narHash": "sha256-dhi3XXT662o1FtP/Li2dIwcQCco6nhT+Yv71dptTlSw=", + "owner": "LoganBarnett", "repo": "nix-darwin", - "rev": "0e6857fa1d632637488666c08e7b02c08e3178f8", + "rev": "27e6a022f25b94010fdb8e5fbbb79608dc589397", "type": "github" }, "original": { - "owner": "lnl7", + "owner": "LoganBarnett", + "ref": "linux-builder-big-config", "repo": "nix-darwin", "type": "github" } diff --git a/flake.nix b/flake.nix index 8902f448..2423a682 100644 --- a/flake.nix +++ b/flake.nix @@ -5,7 +5,8 @@ # Principle inputs nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; - nix-darwin.url = "github:lnl7/nix-darwin"; + # nix-darwin.url = "github:lnl7/nix-darwin"; + nix-darwin.url = "github:LoganBarnett/nix-darwin/linux-builder-big-config"; # https://github.com/LnL7/nix-darwin/pull/878 (for 'systems') nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; home-manager.url = "github:nix-community/home-manager"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; @@ -113,6 +114,7 @@ imports = [ self.darwinModules.default # Defined in nix-darwin/default.nix ./systems/darwin.nix + ./systems/darwin/ci.nix ]; }; naivete = self.nixos-flake.lib.mkMacosSystem { diff --git a/systems/darwin/ci.nix b/systems/darwin/ci.nix new file mode 100644 index 00000000..6a60f891 --- /dev/null +++ b/systems/darwin/ci.nix @@ -0,0 +1,29 @@ +{ ... }: + +{ + # TODO: GitHub Runners + + # To build Linux derivations whilst on macOS. + # + # NOTES: + # - To SSH, `sudo su -` and then `ssh -i /etc/nix/builder_ed25519 builder@linux-builder`. + # Unfortunately, a simple `ssh linux-builder` will not work (Too many authentication failures). + # - To update virtualisation configuration, you have to disable, delete + # /private/var/lib/darwin-builder/ and re-enable. + nix.linux-builder = { + enable = true; + systems = [ + "x86_64-linux" + "aarch64-linux" + ]; + config = { pkgs, lib, ... }: { + boot.binfmt.emulatedSystems = [ "x86_64-linux" ]; + virtualisation = { + # Larger linux-builder cores, ram, and disk. + cores = 6; + memorySize = lib.mkForce (1024 * 16); + diskSize = lib.mkForce (1024 * 1); # In MB. + }; + }; + }; +}