feat(build): enable distributed builds and caching setup
- Added Nix distributed build configuration for multiple machines. - Introduced caching setup with substituters and sandbox paths. - Enabled optional build configurations with ccache support.
This commit is contained in:
parent
55af1a9cad
commit
143e8cbf98
5 changed files with 127 additions and 5 deletions
17
modules/darwin/services/build/default.nix
Normal file
17
modules/darwin/services/build/default.nix
Normal file
|
|
@ -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 { };
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
{
|
{ config
|
||||||
config,
|
, lib
|
||||||
lib,
|
, pkgs
|
||||||
pkgs,
|
, ...
|
||||||
...
|
|
||||||
}:
|
}:
|
||||||
with lib;
|
with lib;
|
||||||
with lib.metacfg;
|
with lib.metacfg;
|
||||||
|
|
|
||||||
23
modules/nixos/services/build/default.nix
Normal file
23
modules/nixos/services/build/default.nix
Normal file
|
|
@ -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
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -4,6 +4,45 @@ with lib.metacfg;
|
||||||
{
|
{
|
||||||
system.defaults.dock.autohide = false;
|
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 = {
|
homebrew = {
|
||||||
enable = true;
|
enable = true;
|
||||||
brews = [
|
brews = [
|
||||||
|
|
@ -27,6 +66,7 @@ with lib.metacfg;
|
||||||
direnv.enable = true;
|
direnv.enable = true;
|
||||||
alacritty.enable = true;
|
alacritty.enable = true;
|
||||||
};
|
};
|
||||||
|
build.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,48 @@
|
||||||
|
|
||||||
with lib.metacfg;
|
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 = {
|
homebrew = {
|
||||||
enable = true;
|
enable = true;
|
||||||
brews = [
|
brews = [
|
||||||
|
|
@ -25,6 +67,7 @@ with lib.metacfg;
|
||||||
direnv.enable = true;
|
direnv.enable = true;
|
||||||
alacritty.enable = true;
|
alacritty.enable = true;
|
||||||
};
|
};
|
||||||
|
build.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue