nixos: distributed builds config init
This commit is contained in:
		
							parent
							
								
									f020ae8902
								
							
						
					
					
						commit
						aa2d8c578e
					
				
					 4 changed files with 62 additions and 14 deletions
				
			
		|  | @ -1,12 +0,0 @@ | ||||||
| { |  | ||||||
|   keys, |  | ||||||
|   config, |  | ||||||
|   ... |  | ||||||
| }: let |  | ||||||
|   inherit (config.ooknet.host) admin; |  | ||||||
| in { |  | ||||||
|   users = { |  | ||||||
|     groups.builder = {}; |  | ||||||
|     users.builder = (key: ''command="nix-daemon --stdio",no-agent-forwarding,no-port-forwarding,no-pty,no-user-rc,no-X11-forwarding ${key}'') keys.users.${admin.name}; |  | ||||||
|   }; |  | ||||||
| } |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| { | { | ||||||
|   imports = [ |   imports = [ | ||||||
|     ./nix.nix |     ./nix.nix | ||||||
|  |     ./distributed-builds.nix | ||||||
|     ./home-manager.nix |     ./home-manager.nix | ||||||
|     ./boot.nix |     ./boot.nix | ||||||
|     ./admin.nix |     ./admin.nix | ||||||
|  |  | ||||||
							
								
								
									
										59
									
								
								modules/nixos/base/distributed-builds.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								modules/nixos/base/distributed-builds.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,59 @@ | ||||||
|  | { | ||||||
|  |   keys, | ||||||
|  |   config, | ||||||
|  |   lib, | ||||||
|  |   self, | ||||||
|  |   ... | ||||||
|  | }: let | ||||||
|  |   inherit (lib) mkIf; | ||||||
|  |   inherit (config.ooknet.host) admin; | ||||||
|  |   inherit (config.networking) hostName; | ||||||
|  | 
 | ||||||
|  |   mkBuilderMachine = { | ||||||
|  |     host, | ||||||
|  |     speedFactor, | ||||||
|  |     systems ? ["x86_64-linux"], | ||||||
|  |     supportedFeatures ? ["big-parallel" "kvm" "nixos-test"], | ||||||
|  |   }: { | ||||||
|  |     inherit speedFactor systems supportedFeatures; | ||||||
|  |     hostName = host; | ||||||
|  |     maxJobs = self.nixosConfigurations.${host}.config.nix.settings.max-jobs or "auto"; | ||||||
|  |     protocol = "ssh"; | ||||||
|  |     sshKey = "/home/${admin.name}/.ssh/builder"; | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   builders = { | ||||||
|  |     ooksdesk = mkBuilderMachine { | ||||||
|  |       host = "ooksdesk"; | ||||||
|  |       speedFactor = 16; | ||||||
|  |     }; | ||||||
|  |     ooksmedia = mkBuilderMachine { | ||||||
|  |       host = "ooksmedia"; | ||||||
|  |       speedFactor = 8; | ||||||
|  |     }; | ||||||
|  |   }; | ||||||
|  | in { | ||||||
|  |   users = mkIf (hostName == "ooksdesk" || hostName == "ooksmedia") { | ||||||
|  |     groups.builder = {}; | ||||||
|  |     users.builder = { | ||||||
|  |       createHome = false; | ||||||
|  |       isSystemUser = true; | ||||||
|  |       useDefaultShell = true; | ||||||
|  |       group = "builder"; | ||||||
|  |       openssh.authorizedKeys.keys = [ | ||||||
|  |         '' | ||||||
|  |           command="nix-daemon --stdio",no-agent-forwarding,no-port-forwarding,no-pty,no-user-rc,no-X11-forwarding ${keys.users.${admin.name}} | ||||||
|  |         '' | ||||||
|  |       ]; | ||||||
|  |     }; | ||||||
|  |   }; | ||||||
|  |   nix = { | ||||||
|  |     distributedBuilds = true; | ||||||
|  |     buildMachines = | ||||||
|  |       if hostName == "ooksdesk" | ||||||
|  |       then [] | ||||||
|  |       else if hostName == "ooksmedia" | ||||||
|  |       then [builders.ooksdesk] | ||||||
|  |       else [builders.ooksdesk builders.ooksmedia]; | ||||||
|  |   }; | ||||||
|  | } | ||||||
|  | @ -44,8 +44,9 @@ in { | ||||||
|     settings = { |     settings = { | ||||||
|       trusted-users = ["@wheel" "root" "builder"]; |       trusted-users = ["@wheel" "root" "builder"]; | ||||||
|       experimental-features = ["nix-command" "flakes"]; |       experimental-features = ["nix-command" "flakes"]; | ||||||
|       accept-flake-config = true; |       accept-flake-config = false; | ||||||
|       auto-optimise-store = true; |       auto-optimise-store = true; | ||||||
|  |       warn-dirty = false; | ||||||
|       # cache |       # cache | ||||||
|       substituters = [ |       substituters = [ | ||||||
|         "https://cache.nixos.org?priority=10" |         "https://cache.nixos.org?priority=10" | ||||||
|  | @ -57,7 +58,6 @@ in { | ||||||
|         "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" |         "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" | ||||||
|         "neovim-flake.cachix.org-1:iyQ6lHFhnB5UkVpxhQqLJbneWBTzM8LBYOFPLNH4qZw=" |         "neovim-flake.cachix.org-1:iyQ6lHFhnB5UkVpxhQqLJbneWBTzM8LBYOFPLNH4qZw=" | ||||||
|       ]; |       ]; | ||||||
|       # TODO: setup builders -- builders-use-substitutes = true; |  | ||||||
|     }; |     }; | ||||||
|   }; |   }; | ||||||
|   nixpkgs = { |   nixpkgs = { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue