Move network settings to module, add build2
This commit is contained in:
parent
52fc46135e
commit
64f8ea814f
2 changed files with 73 additions and 33 deletions
89
flake.nix
89
flake.nix
|
@ -24,6 +24,7 @@
|
|||
dockerModule = import ./modules/docker;
|
||||
subvolumesModule = import ./modules/subvolumes;
|
||||
k3sModule = import ./modules/k3s;
|
||||
networkModule = import ./modules/network;
|
||||
|
||||
makeConfig = { hostname, extraModules ? [ ] }:
|
||||
with image-builder.packages.aarch64-linux.modules;
|
||||
|
@ -39,7 +40,7 @@
|
|||
] ++ extraModules;
|
||||
};
|
||||
|
||||
makeGenericK3sConfig = { hostname, macAddress ? null, enableK3s ? true, selfIp, serverIp ? null, extraModules ? [ ] }:
|
||||
makeGenericK3sConfig = { hostname, enableK3s ? true, serverIp ? null, extraModules ? [ ] }:
|
||||
with image-builder.packages.aarch64-linux.modules;
|
||||
makeConfig {
|
||||
inherit hostname;
|
||||
|
@ -58,20 +59,6 @@
|
|||
services.lvm.enable = true;
|
||||
services.rpcbind.enable = true;
|
||||
|
||||
networking = {
|
||||
interfaces.end0 = {
|
||||
inherit macAddress;
|
||||
ipv4.addresses = [
|
||||
{
|
||||
address = selfIp;
|
||||
prefixLength = 24;
|
||||
}
|
||||
];
|
||||
};
|
||||
defaultGateway = "192.168.20.1";
|
||||
nameservers = [ "192.168.20.21" "192.168.20.1" ];
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
nfs-utils
|
||||
];
|
||||
|
@ -81,9 +68,12 @@
|
|||
|
||||
makeBoardK3sConfig = module: { hostname, macAddress ? null, enableK3s ? true, selfIp, serverIp }:
|
||||
makeGenericK3sConfig {
|
||||
inherit hostname macAddress enableK3s selfIp serverIp;
|
||||
inherit hostname enableK3s serverIp;
|
||||
|
||||
extraModules = [ module ];
|
||||
extraModules = [
|
||||
(networkModule { inherit macAddress selfIp; })
|
||||
module
|
||||
];
|
||||
};
|
||||
|
||||
makeRock64K3sConfig = makeBoardK3sConfig image-builder.packages.aarch64-linux.modules.rock64;
|
||||
|
@ -105,12 +95,15 @@
|
|||
];
|
||||
in
|
||||
makeGenericK3sConfig {
|
||||
inherit hostname selfIp serverIp;
|
||||
inherit hostname serverIp;
|
||||
|
||||
enableK3s = unlockMounts && mountVolumes && enableK3s;
|
||||
|
||||
extraModules = [
|
||||
soquartz-blade
|
||||
(networkModule {
|
||||
inherit selfIp;
|
||||
})
|
||||
(btrbkModule {
|
||||
instances = [
|
||||
{
|
||||
|
@ -274,6 +267,40 @@
|
|||
];
|
||||
};
|
||||
|
||||
makeBuildConfig = { hostname, macAddress ? null, selfIp }:
|
||||
with image-builder.packages.aarch64-linux.modules;
|
||||
let
|
||||
device = "/btrfs.4G";
|
||||
mountDir = "/btrfs/loop";
|
||||
subvolumes = [
|
||||
"@build-cfg"
|
||||
];
|
||||
in
|
||||
makeConfig {
|
||||
inherit hostname;
|
||||
|
||||
extraModules = [
|
||||
rockPro64v2
|
||||
dockerModule
|
||||
(networkModule { inherit macAddress selfIp; })
|
||||
(btrbkModule {
|
||||
instances = [
|
||||
{ inherit mountDir subvolumes; }
|
||||
];
|
||||
})
|
||||
(subvolumesModule {
|
||||
inherit device subvolumes;
|
||||
})
|
||||
{
|
||||
fileSystems."${mountDir}" = {
|
||||
inherit device;
|
||||
fsType = "btrfs";
|
||||
options = [ "defaults" "compress=zstd" "rw" "loop" ];
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
makeNextcloudConfig = { hostname, primaryIp ? null }:
|
||||
with image-builder.packages.aarch64-linux.modules;
|
||||
let
|
||||
|
@ -348,6 +375,7 @@
|
|||
extraModules = [
|
||||
rock64
|
||||
dockerModule
|
||||
(networkModule { inherit macAddress selfIp; })
|
||||
(btrbkModule {
|
||||
instances = [{
|
||||
inherit mountDir primaryIp subvolumes;
|
||||
|
@ -380,21 +408,6 @@
|
|||
options = [ "defaults" "compress=zstd" "rw" ];
|
||||
};
|
||||
})
|
||||
{
|
||||
networking = {
|
||||
interfaces.end0 = {
|
||||
inherit macAddress;
|
||||
ipv4.addresses = [
|
||||
{
|
||||
address = selfIp;
|
||||
prefixLength = 24;
|
||||
}
|
||||
];
|
||||
};
|
||||
defaultGateway = "192.168.20.1";
|
||||
nameservers = [ "192.168.20.21" "192.168.20.1" ];
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
|
@ -457,6 +470,11 @@
|
|||
primaryIp = "192.168.20.11";
|
||||
};
|
||||
|
||||
build2 = makeBuildConfig {
|
||||
hostname = "build2";
|
||||
selfIp = "192.168.20.101";
|
||||
};
|
||||
|
||||
k3s1 = makeSoQuartzK3sConfig {
|
||||
hostname = "k3s1";
|
||||
selfIp = "192.168.20.120";
|
||||
|
@ -555,6 +573,11 @@
|
|||
configuration = self.nixosConfigurations.nextcloud2;
|
||||
};
|
||||
|
||||
deploy.nodes.build2 = deployer {
|
||||
hostname = "192.168.20.101";
|
||||
configuration = self.nixosConfigurations.build2;
|
||||
};
|
||||
|
||||
deploy.nodes.k3s1 = deployer {
|
||||
hostname = "192.168.20.120";
|
||||
configuration = self.nixosConfigurations.k3s1;
|
||||
|
|
17
modules/network/default.nix
Normal file
17
modules/network/default.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{ macAddress ? null, selfIp }:
|
||||
|
||||
{
|
||||
networking = {
|
||||
interfaces.end0 = {
|
||||
inherit macAddress;
|
||||
ipv4.addresses = [
|
||||
{
|
||||
address = selfIp;
|
||||
prefixLength = 24;
|
||||
}
|
||||
];
|
||||
};
|
||||
defaultGateway = "192.168.20.1";
|
||||
nameservers = [ "192.168.20.21" "192.168.20.1" ];
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue