1
0
Fork 0

Add support for remote Nix builders

This commit is contained in:
Aires 2024-05-01 09:35:38 -04:00
parent ce959a747c
commit 2667732682
5 changed files with 47 additions and 29 deletions

View file

@ -39,12 +39,8 @@
}; };
}; };
# Limit number of simultaneous builds so we have two free cores. # Build remotely
# 5 max jobs * 2 cores each = 10 cores in total. nix.distributedBuilds = true;
nix.settings = {
max-jobs = 2;
cores = 10;
};
# Configure the virtual machine created by nixos-rebuild build-vm # Configure the virtual machine created by nixos-rebuild build-vm
virtualisation.vmVariant.virtualisation = { virtualisation.vmVariant.virtualisation = {

View file

@ -3,6 +3,7 @@
./bluetooth.nix ./bluetooth.nix
./bootloader.nix ./bootloader.nix
./network.nix ./network.nix
./nix.nix
./shell.nix ./shell.nix
./system.nix ./system.nix
]; ];

42
modules/base/nix.nix Normal file
View file

@ -0,0 +1,42 @@
# Nix configuration
{ pkgs, config, lib, inputs, ... }: {
nix = {
# Use the latest and greatest Nix
package = pkgs.nixVersions.unstable;
settings = {
# Enables Flakes
experimental-features = [ "nix-command" "flakes" ];
# Avoid signature verification messages when doing remote builds
trusted-users = [ "${config.users.users.aires.name}" ];
};
# Enable periodic nix store optimization
optimise.automatic = true;
# Configure NixOS to use the same software channel as Flakes
registry = lib.mapAttrs (_: value: { flake = value; }) inputs;
nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry;
# Configure remote build machines (mainly Haven)
# To enable remote builds for a specific host, add `nix.distributedBuilds = true;` to its config
buildMachines = [{
hostName = "haven";
systems = [
"x86_64-linux"
"aarch64-linux"
];
protocol = "ssh-ng";
supportedFeatures = [
"nixos-test"
"kvm"
];
}];
# When using a builder, use its package store
extraOptions = ''
builders-use-substitutes = true
'';
};
}

View file

@ -69,27 +69,6 @@ with lib;
}; };
}; };
# Configure nix
nix = {
# Use the latest and greatest Nix
package = pkgs.nixVersions.unstable;
settings = {
# Enables Flakes
experimental-features = [ "nix-command" "flakes" ];
# Avoid signature verification messages when doing remote builds
trusted-users = [ "${config.users.users.aires.name}" ];
};
# Enable periodic nix store optimization
optimise.automatic = true;
# Configure NixOS to use the same software channel as Flakes
registry = lib.mapAttrs (_: value: { flake = value; }) inputs;
nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry;
};
# Set up base apps # Set up base apps
programs = { programs = {
direnv.enable = true; direnv.enable = true;