mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-07-11 23:22:40 +02:00
feat: simplify flake.nix
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{ ... }: {
|
||||
|
||||
{ username, ... }:
|
||||
{
|
||||
####################################################################
|
||||
#
|
||||
# NixOS's Configuration for Remote Building / Distributed Building
|
||||
@@ -8,68 +8,67 @@
|
||||
# 1. https://github.com/NixOS/nix/issues/7380
|
||||
# 2. https://nixos.wiki/wiki/Distributed_build
|
||||
# 3. https://github.com/NixOS/nix/issues/2589
|
||||
#
|
||||
####################################################################
|
||||
|
||||
# set local's max-job to 0 to force remote building(disable local building)
|
||||
# nix.settings.max-jobs = 0;
|
||||
nix.distributedBuilds = true;
|
||||
nix.buildMachines =
|
||||
let
|
||||
sshUser = "ryan";
|
||||
# ssh key's path on local machine
|
||||
sshKey = "/home/ryan/.ssh/ai-idols";
|
||||
systems = [
|
||||
# native arch
|
||||
"x86_64-linux"
|
||||
nix.buildMachines = let
|
||||
sshUser = username;
|
||||
# ssh key's path on local machine
|
||||
sshKey = "/home/${username}/.ssh/ai-idols";
|
||||
systems = [
|
||||
# native arch
|
||||
"x86_64-linux"
|
||||
|
||||
# emulated arch using binfmt_misc and qemu-user
|
||||
"aarch64-linux"
|
||||
"riscv64-linux"
|
||||
];
|
||||
# all available system features are poorly documentd here:
|
||||
# https://github.com/NixOS/nix/blob/e503ead/src/libstore/globals.hh#L673-L687
|
||||
supportedFeatures = [
|
||||
"benchmark"
|
||||
"big-parallel"
|
||||
"kvm"
|
||||
];
|
||||
in
|
||||
[
|
||||
# Nix seems always try to build on the machine remotely
|
||||
# to make use of the local machine's high-performance CPU, do not set remote builder's maxJobs too high.
|
||||
{
|
||||
# some of my remote builders are running NixOS
|
||||
# and has the same sshUser, sshKey, systems, etc.
|
||||
inherit sshUser sshKey systems supportedFeatures;
|
||||
# emulated arch using binfmt_misc and qemu-user
|
||||
"aarch64-linux"
|
||||
"riscv64-linux"
|
||||
];
|
||||
# all available system features are poorly documentd here:
|
||||
# https://github.com/NixOS/nix/blob/e503ead/src/libstore/globals.hh#L673-L687
|
||||
supportedFeatures = [
|
||||
"benchmark"
|
||||
"big-parallel"
|
||||
"kvm"
|
||||
];
|
||||
in [
|
||||
# Nix seems always try to build on the machine remotely
|
||||
# to make use of the local machine's high-performance CPU, do not set remote builder's maxJobs too high.
|
||||
{
|
||||
# some of my remote builders are running NixOS
|
||||
# and has the same sshUser, sshKey, systems, etc.
|
||||
inherit sshUser sshKey systems supportedFeatures;
|
||||
|
||||
# the hostName should be:
|
||||
# 1. a hostname that can be resolved by DNS
|
||||
# 2. the ip address of the remote builder
|
||||
# 3. a host alias defined globally in /etc/ssh/ssh_config
|
||||
hostName = "aquamarine";
|
||||
# remote builder's max-job
|
||||
maxJobs = 3;
|
||||
# speedFactor's a signed integer
|
||||
# but it seems that it's not used by Nix, takes no effect
|
||||
speedFactor = 1;
|
||||
}
|
||||
{
|
||||
inherit sshUser sshKey systems supportedFeatures;
|
||||
hostName = "ruby";
|
||||
maxJobs = 2;
|
||||
speedFactor = 1;
|
||||
}
|
||||
{
|
||||
inherit sshUser sshKey systems supportedFeatures;
|
||||
hostName = "kana";
|
||||
maxJobs = 2;
|
||||
speedFactor = 1;
|
||||
}
|
||||
];
|
||||
# the hostName should be:
|
||||
# 1. a hostname that can be resolved by DNS
|
||||
# 2. the ip address of the remote builder
|
||||
# 3. a host alias defined globally in /etc/ssh/ssh_config
|
||||
hostName = "aquamarine";
|
||||
# remote builder's max-job
|
||||
maxJobs = 3;
|
||||
# speedFactor's a signed integer
|
||||
# but it seems that it's not used by Nix, takes no effect
|
||||
speedFactor = 1;
|
||||
}
|
||||
{
|
||||
inherit sshUser sshKey systems supportedFeatures;
|
||||
hostName = "ruby";
|
||||
maxJobs = 2;
|
||||
speedFactor = 1;
|
||||
}
|
||||
{
|
||||
inherit sshUser sshKey systems supportedFeatures;
|
||||
hostName = "kana";
|
||||
maxJobs = 2;
|
||||
speedFactor = 1;
|
||||
}
|
||||
];
|
||||
# optional, useful when the builder has a faster internet connection than yours
|
||||
nix.extraOptions = ''
|
||||
builders-use-substitutes = true
|
||||
'';
|
||||
nix.extraOptions = ''
|
||||
builders-use-substitutes = true
|
||||
'';
|
||||
|
||||
# define the host alias for remote builders
|
||||
# this config will be written to /etc/ssh/ssh_config
|
||||
@@ -77,11 +76,11 @@
|
||||
Host ai
|
||||
HostName 192.168.5.100
|
||||
Port 22
|
||||
|
||||
|
||||
Host aquamarine
|
||||
HostName 192.168.5.101
|
||||
Port 22
|
||||
|
||||
|
||||
Host ruby
|
||||
HostName 192.168.5.102
|
||||
Port 22
|
||||
@@ -96,19 +95,19 @@
|
||||
programs.ssh.knownHosts = {
|
||||
# 星野 愛久愛海, Hoshino Aquamarine
|
||||
aquamarine = {
|
||||
hostNames = [ "aquamarine" "192.168.5.101" ];
|
||||
hostNames = ["aquamarine" "192.168.5.101"];
|
||||
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDnCQXlllHoLX5EvU+t6yP/npsmuxKt0skHVeJashizE";
|
||||
};
|
||||
|
||||
# 星野 瑠美衣, Hoshino Rubii
|
||||
ruby = {
|
||||
hostNames = [ "ruby" "192.168.5.102" ];
|
||||
hostNames = ["ruby" "192.168.5.102"];
|
||||
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE7n11XxB8B3HjdyAsL3PuLVDZxWCzEOUTJAY8+goQmW";
|
||||
};
|
||||
|
||||
# 有馬 かな, Arima Kana
|
||||
kana = {
|
||||
hostNames = [ "kana" "192.168.5.103" ];
|
||||
hostNames = ["kana" "192.168.5.103"];
|
||||
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ3dDLOZERP1nZfRz3zIeVDm1q2Trer+fWFVvVXrgXM1";
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user