diff --git a/modules/darwin/services/build/default.nix b/modules/darwin/services/build/default.nix new file mode 100644 index 0000000..9d4a443 --- /dev/null +++ b/modules/darwin/services/build/default.nix @@ -0,0 +1,17 @@ +{ config +, lib +, pkgs +, ... +}: +with lib; +with lib.metacfg; +let + cfg = config.metacfg.build; +in +{ + options.metacfg.build = with types; { + enable = mkBoolOpt false "Whether or not to enable the build config."; + }; + + config = mkIf cfg.enable { }; +} diff --git a/modules/nixos/services/base/default.nix b/modules/nixos/services/base/default.nix index 273d05a..550b9d3 100644 --- a/modules/nixos/services/base/default.nix +++ b/modules/nixos/services/base/default.nix @@ -1,8 +1,7 @@ -{ - config, - lib, - pkgs, - ... +{ config +, lib +, pkgs +, ... }: with lib; with lib.metacfg; diff --git a/modules/nixos/services/build/default.nix b/modules/nixos/services/build/default.nix new file mode 100644 index 0000000..8f1aabb --- /dev/null +++ b/modules/nixos/services/build/default.nix @@ -0,0 +1,23 @@ +{ config +, lib +, pkgs +, ... +}: +with lib; +with lib.metacfg; +let + cfg = config.metacfg.build; +in +{ + options.metacfg.build = with types; { + enable = mkBoolOpt false "Whether or not to enable the build config."; + }; + + config = mkIf cfg.enable { + programs.ccache.enable = true; + nix.settings.extra-sandbox-paths = [ "/var/cache/ccache" ]; + environment.systemPackages = [ + pkgs.ccache + ]; + }; +} diff --git a/systems/aarch64-darwin/m4/default.nix b/systems/aarch64-darwin/m4/default.nix index 63ca8fd..c4f301b 100644 --- a/systems/aarch64-darwin/m4/default.nix +++ b/systems/aarch64-darwin/m4/default.nix @@ -4,6 +4,45 @@ with lib.metacfg; { system.defaults.dock.autohide = false; + nix.distributedBuilds = true; + + nix.buildMachines = [ + { + hostName = "m1.local"; + system = "aarch64-darwin"; + maxJobs = 4; + speedFactor = 2; + sshUser = "harald"; + sshKey = "/etc/ssh/nix-builder-key"; + } + { + hostName = "rialo.local"; + system = "aarch64-darwin"; + maxJobs = 4; + speedFactor = 2; + sshUser = "harald"; + sshKey = "/etc/ssh/nix-builder-key"; + } + { + hostName = "sgx.local"; + system = "x86_64-linux"; + maxJobs = 4; + speedFactor = 1; + sshUser = "harald"; + sshKey = "/etc/ssh/nix-builder-key"; + } + ]; + + nix.settings = { + substituters = [ + "https://cache.nixos.org" + "ssh-ng://harald@m4.local?ssh-key=/etc/ssh/nix-builder-key" + "ssh-ng://harald@rialo.local?ssh-key=/etc/ssh/nix-builder-key" + ]; + + builders-use-substitutes = true; + }; + homebrew = { enable = true; brews = [ @@ -27,6 +66,7 @@ with lib.metacfg; direnv.enable = true; alacritty.enable = true; }; + build.enable = true; }; environment.systemPackages = with pkgs; [ diff --git a/systems/aarch64-darwin/rialo/default.nix b/systems/aarch64-darwin/rialo/default.nix index 792d425..0526224 100644 --- a/systems/aarch64-darwin/rialo/default.nix +++ b/systems/aarch64-darwin/rialo/default.nix @@ -2,6 +2,48 @@ with lib.metacfg; { + + + nix.distributedBuilds = true; + + nix.buildMachines = [ + { + hostName = "m1.local"; + system = "aarch64-darwin"; + maxJobs = 4; + speedFactor = 2; + sshUser = "harald"; + sshKey = "/etc/ssh/nix-builder-key"; + } + { + hostName = "rialo.local"; + system = "aarch64-darwin"; + maxJobs = 4; + speedFactor = 2; + sshUser = "harald"; + sshKey = "/etc/ssh/nix-builder-key"; + } + { + hostName = "sgx.local"; + system = "x86_64-linux"; + maxJobs = 4; + speedFactor = 1; + sshUser = "harald"; + sshKey = "/etc/ssh/nix-builder-key"; + } + ]; + + nix.settings = { + substituters = [ + "https://cache.nixos.org" + "ssh-ng://harald@m4.local?ssh-key=/etc/ssh/nix-builder-key" + "ssh-ng://harald@rialo.local?ssh-key=/etc/ssh/nix-builder-key" + ]; + + builders-use-substitutes = true; + }; + + homebrew = { enable = true; brews = [ @@ -25,6 +67,7 @@ with lib.metacfg; direnv.enable = true; alacritty.enable = true; }; + build.enable = true; }; environment.systemPackages = with pkgs; [