diff --git a/hosts/hl-minipc1.nix b/hosts/hl-minipc1.nix index 2b7374d..a4535f8 100644 --- a/hosts/hl-minipc1.nix +++ b/hosts/hl-minipc1.nix @@ -8,6 +8,7 @@ }; # firmware updater services.fwupd.enable = true; + homelab.nix.remote-builder = true; # Bootloader. boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; diff --git a/hosts/hl-minipc2.nix b/hosts/hl-minipc2.nix index 3084d27..82331fe 100644 --- a/hosts/hl-minipc2.nix +++ b/hosts/hl-minipc2.nix @@ -6,6 +6,7 @@ # Bootloader. boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; + homelab.nix.remote-builder = true; # Special udev rule for google's coral tpu homelab.udevrules.coraltpu.enable = true; } diff --git a/hosts/hl-terra1.nix b/hosts/hl-terra1.nix index c7a991e..de27582 100644 --- a/hosts/hl-terra1.nix +++ b/hosts/hl-terra1.nix @@ -7,5 +7,6 @@ boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; homelab.hardware.fan2go.enable = true; + homelab.nix.remote-builder = true; } diff --git a/modules/nix/default.nix b/modules/nix/default.nix index b07705c..b39f425 100644 --- a/modules/nix/default.nix +++ b/modules/nix/default.nix @@ -1,6 +1,11 @@ { user, systemStateVersion, localNixCaches ? { keys = [ ]; urls = [ ]; } }: { pkgs, ... }: { + imports = [ + (import ./remote-builder.nix { + user = user; + }) + ]; # Nix core system.stateVersion = systemStateVersion; nixpkgs.config.allowUnfree = true; diff --git a/modules/nix/remote-builder.nix b/modules/nix/remote-builder.nix new file mode 100644 index 0000000..2e619d1 --- /dev/null +++ b/modules/nix/remote-builder.nix @@ -0,0 +1,28 @@ +{ user }: +{ config, lib, ... }: +with lib; +let cfg = config.homelab.nix.remote-builder; +in { + options = { + homelab.nix.remote-builder = { + enable = mkEnableOption + "Enable Remote Local Builders"; + }; + }; + config = mkIf cfg.enable { + nix.buildMachines = [{ + hostName = "bigbox1.lab.internal"; + sshUser = user.name; + system = "x86_64-linux"; + protocol = "ssh-ng"; + maxJobs = 4; + speedFactor = 4; + supportedFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ]; + mandatoryFeatures = [ ]; + }]; + nix.distributedBuilds = true; + nix.extraOptions = '' + builders-use-substitutes = true + ''; + }; +}