Refactor the Nix config management.
This commit is contained in:
parent
55fe63bcdb
commit
aca053b4e1
23 changed files with 954 additions and 1764 deletions
50
nix-system-configs/modules/toolsets/remote_building.nix
Normal file
50
nix-system-configs/modules/toolsets/remote_building.nix
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
# THE FOLLOWING CODE BLOCK IS FOR COPYING TO OTHER CONFIGURATIONS, NOT FOR THIS FILE
|
||||
|
||||
nix.distributedBuilds = true;
|
||||
nix.buildMachines = [
|
||||
{
|
||||
hostName = "nixos-build-machine";
|
||||
system = "x86_64-linux";
|
||||
sshUser = "nixremote";
|
||||
sshKey = "/root/.ssh/nixremote";
|
||||
maxJobs = 4;
|
||||
speedFactor = 2;
|
||||
supportedFeatures = ["nixos-test" "benchmark" "big-parallel" "kvm"];
|
||||
}
|
||||
];
|
||||
|
||||
# Generate SSH key for remote building
|
||||
systemd.services.generate-nixremote-key = {
|
||||
description = "Generate SSH key for remote Nix builds";
|
||||
wantedBy = ["multi-user.target"];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
};
|
||||
script = ''
|
||||
if [ ! -f /root/.ssh/nixremote ]; then
|
||||
${pkgs.openssh}/bin/ssh-keygen -t ed25519 -f /root/.ssh/nixremote -N "" -C "nix-remote-builder"
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
programs.ssh.extraConfig = ''
|
||||
Host nixos-build-machine
|
||||
HostName 10.1.1.3
|
||||
IdentitiesOnly yes
|
||||
IdentityFile /root/.ssh/nixremote
|
||||
User nixremoteStrictHostKeyChecking accept-new
|
||||
'';
|
||||
|
||||
# Manual step required: After rebuilding the client, copy /root/.ssh/nixremote.pub
|
||||
# from the client to the build machine's users.users.nixremote.openssh.authorizedKeys.keys list,
|
||||
# then rebuild the build machine.
|
||||
# i.e on the client: run "cat /root.ssh/nixremote.pub"
|
||||
# and copy the output to the build machine's configuration.nix
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue