1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-07-29 02:57:44 +00:00

feat: add best as a distribured builder

This commit is contained in:
RGBCube 2025-02-25 22:33:25 +03:00
parent a7c9b60944
commit 20ce1c9ff5
Signed by: RGBCube
SSH key fingerprint: SHA256:CzqbPcfwt+GxFYNnFVCqoN5Itn4YFrshg1TrnACpA5M
4 changed files with 38 additions and 15 deletions

View file

@ -28,7 +28,7 @@
flake-registry = ""; flake-registry = "";
http-connections = 50; http-connections = 50;
show-trace = true; show-trace = true;
trusted-users = [ "root" "@wheel" "@admin" ]; trusted-users = [ "root" "@build" "@wheel" "@admin" ];
use-cgroups = true; use-cgroups = true;
warn-dirty = false; warn-dirty = false;
}; };

View file

@ -27,6 +27,14 @@ in {
hashedPasswordFile = config.secrets.thePassword.path; hashedPasswordFile = config.secrets.thePassword.path;
isNormalUser = true; isNormalUser = true;
}; };
build = {
description = "Build";
openssh.authorizedKeys.keys = keys.all;
hashedPasswordFile = config.secrets.thePassword.path;
isNormalUser = true;
extraGroups = [ "build" ];
};
}; };
home-manager.users = { home-manager.users = {

View file

@ -1,10 +1,6 @@
{ config, lib, pkgs, ... }: let { config, lib, pkgs, ... }: let
inherit (lib) const enabled flip genAttrs mkForce mkOverride mkValue; inherit (lib) const enabled flip genAttrs mkForce mkOverride mkValue;
in { in {
config.environment.systemPackages = [
config.services.postgresql.package
];
config.services.prometheus.exporters.postgres = enabled { config.services.prometheus.exporters.postgres = enabled {
listenAddress = "[::]"; listenAddress = "[::]";
runAsLocalSuperUser = true; runAsLocalSuperUser = true;
@ -26,6 +22,10 @@ in {
options.services.postgresql.ensure = mkValue []; options.services.postgresql.ensure = mkValue [];
config.environment.systemPackages = [
config.services.postgresql.package
];
config.services.postgresql = enabled { config.services.postgresql = enabled {
package = pkgs.postgresql_14; package = pkgs.postgresql_14;

View file

@ -1,5 +1,5 @@
{ self, config, inputs, lib, pkgs, ... }: let { self, config, inputs, lib, pkgs, ... }: let
inherit (lib) concatStringsSep const disabled filterAttrs flip id isType mapAttrs mapAttrsToList merge mkAfter optionalAttrs; inherit (lib) attrsToList concatStringsSep const disabled filter filterAttrs flip id isType mapAttrs mapAttrsToList merge mkAfter optionalAttrs;
inherit (lib.strings) toJSON; inherit (lib.strings) toJSON;
registryMap = inputs registryMap = inputs
@ -9,18 +9,23 @@ in {
# that happens rebuilds are slow thanks to my garbage WiFi. # that happens rebuilds are slow thanks to my garbage WiFi.
environment.etc.".system-inputs.json".text = toJSON registryMap; environment.etc.".system-inputs.json".text = toJSON registryMap;
nix.nixPath = registryMap nix.distributedBuilds = true;
|> mapAttrsToList (name: value: "${name}=${value}") nix.buildMachines = self.nixosConfigurations
|> (if config.isDarwin then concatStringsSep ":" else id); |> attrsToList
|> filter ({ name, value }:
nix.registry = registryMap // { default = inputs.nixpkgs; } name != config.networking.hostName &&
|> mapAttrs (_: flake: { inherit flake; }); value.config.users.users ? build)
|> map ({ name, value }: {
hostName = name;
maxJobs = 20;
protocol = "ssh-ng";
sshUser = "build";
supportedFeatures = [ "kvm" "big-parallel" ];
system = value.config.nixpkgs.hostPlatform.system;
});
nix.channel = disabled; nix.channel = disabled;
nix.settings = (import <| self + /flake.nix).nixConfig
|> flip removeAttrs (if config.isDarwin then [ "use-cgroups" ] else []);
nix.gc = merge { nix.gc = merge {
automatic = true; automatic = true;
options = "--delete-older-than 3d"; options = "--delete-older-than 3d";
@ -29,6 +34,16 @@ in {
persistent = true; persistent = true;
}; };
nix.nixPath = registryMap
|> mapAttrsToList (name: value: "${name}=${value}")
|> (if config.isDarwin then concatStringsSep ":" else id);
nix.registry = registryMap // { default = inputs.nixpkgs; }
|> mapAttrs (_: flake: { inherit flake; });
nix.settings = (import <| self + /flake.nix).nixConfig
|> flip removeAttrs (if config.isDarwin then [ "use-cgroups" ] else []);
nix.optimise.automatic = true; nix.optimise.automatic = true;
environment.systemPackages = [ environment.systemPackages = [