2023-01-25 01:58:10 +00:00
|
|
|
{
|
|
|
|
description = "A very basic flake";
|
|
|
|
|
|
|
|
inputs = {
|
2023-01-26 03:26:30 +00:00
|
|
|
deploy-rs = {
|
|
|
|
url = "github:serokell/deploy-rs";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2023-02-19 18:27:13 +00:00
|
|
|
sd-images = {
|
2023-05-08 18:43:41 +00:00
|
|
|
url =
|
|
|
|
"git+https://git.asonix.dog/asonix/sd-images?ref=asonix/nabam-sd-image";
|
2023-04-21 22:05:58 +00:00
|
|
|
inputs.nixpkgsUnstable.follows = "nixpkgs";
|
2023-01-28 00:32:14 +00:00
|
|
|
};
|
2023-03-03 22:11:43 +00:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
2023-01-26 03:26:30 +00:00
|
|
|
sops-nix = {
|
|
|
|
url = "github:Mic92/sops-nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2023-01-25 01:58:10 +00:00
|
|
|
};
|
|
|
|
|
2023-02-19 18:27:13 +00:00
|
|
|
outputs = { self, deploy-rs, sd-images, nixpkgs, sops-nix }:
|
2023-01-25 04:23:29 +00:00
|
|
|
let
|
2023-01-27 00:08:51 +00:00
|
|
|
sharedModule = import ./modules/shared;
|
|
|
|
btrbkModule = import ./modules/btrbk;
|
|
|
|
dockerModule = import ./modules/docker;
|
|
|
|
subvolumesModule = import ./modules/subvolumes;
|
|
|
|
k3sModule = import ./modules/k3s;
|
2023-02-11 04:47:38 +00:00
|
|
|
networkModule = import ./modules/network;
|
2023-06-07 20:04:46 +00:00
|
|
|
wireguardModule = import ./modules/wireguard;
|
2023-06-07 22:24:40 +00:00
|
|
|
desktopModule = import ./modules/desktop;
|
2023-06-07 23:10:43 +00:00
|
|
|
serverModule = import ./modules/server;
|
2023-01-26 03:26:30 +00:00
|
|
|
|
2023-01-27 00:08:51 +00:00
|
|
|
makeConfig = { hostname, extraModules ? [ ] }:
|
2023-01-26 18:02:00 +00:00
|
|
|
nixpkgs.lib.nixosSystem {
|
|
|
|
system = "aarch64-linux";
|
|
|
|
modules = [
|
|
|
|
sops-nix.nixosModules.sops
|
|
|
|
sharedModule
|
2023-05-08 18:43:41 +00:00
|
|
|
{ networking.hostName = hostname; }
|
2023-01-26 18:02:00 +00:00
|
|
|
] ++ extraModules;
|
|
|
|
};
|
2023-01-26 06:57:59 +00:00
|
|
|
|
2023-06-07 23:10:43 +00:00
|
|
|
makeServerConfig = { hostname, extraModules ? [ ] }:
|
|
|
|
makeConfig {
|
|
|
|
inherit hostname;
|
|
|
|
extraModules = [ (serverModule) ] ++ extraModules;
|
|
|
|
};
|
|
|
|
|
|
|
|
makeDesktopConfig = { hostname, extraModules ? [ ] }:
|
|
|
|
makeConfig {
|
|
|
|
inherit hostname;
|
|
|
|
extraModules = [ (desktopModule) ] ++ extraModules;
|
|
|
|
};
|
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
makeGenericK3sConfig =
|
|
|
|
{ hostname, enableK3s ? true, serverIp ? null, extraModules ? [ ] }:
|
2023-06-07 23:10:43 +00:00
|
|
|
makeServerConfig {
|
2023-02-03 14:59:52 +00:00
|
|
|
inherit hostname;
|
|
|
|
|
|
|
|
extraModules = [
|
2023-05-08 18:43:41 +00:00
|
|
|
(if serverIp == null then
|
2023-02-03 14:59:52 +00:00
|
|
|
k3sModule.server { enable = enableK3s; }
|
|
|
|
else
|
|
|
|
k3sModule.agent {
|
|
|
|
inherit serverIp;
|
|
|
|
enable = enableK3s;
|
|
|
|
})
|
2023-05-08 18:43:41 +00:00
|
|
|
({ config, pkgs, ... }: {
|
|
|
|
services.lvm.enable = true;
|
|
|
|
services.rpcbind.enable = true;
|
2023-02-03 14:59:52 +00:00
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
environment.systemPackages = with pkgs; [ nfs-utils ];
|
|
|
|
})
|
2023-02-03 14:59:52 +00:00
|
|
|
] ++ extraModules;
|
|
|
|
};
|
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
makeBoardK3sConfig = modules:
|
|
|
|
{ hostname, macAddress ? null, enableK3s ? true, selfIp, serverIp }:
|
2023-02-03 14:59:52 +00:00
|
|
|
makeGenericK3sConfig {
|
2023-02-11 04:47:38 +00:00
|
|
|
inherit hostname enableK3s serverIp;
|
2023-02-03 14:59:52 +00:00
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
extraModules = [ (networkModule { inherit macAddress selfIp; }) ]
|
|
|
|
++ modules;
|
2023-02-03 14:59:52 +00:00
|
|
|
};
|
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
makeRock64K3sConfig = system:
|
|
|
|
makeBoardK3sConfig sd-images.packages.${system}.Rock64.modules;
|
2023-02-04 03:18:16 +00:00
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
makeRockPro64K3sConfig = system:
|
|
|
|
makeBoardK3sConfig sd-images.packages.${system}.RockPro64v2.modules;
|
2023-02-04 03:18:16 +00:00
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
makeQuartz64AK3sConfig = system:
|
|
|
|
makeBoardK3sConfig sd-images.packages.${system}.Quartz64A.modules;
|
2023-02-04 03:18:16 +00:00
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
makeOldSoQuartzK3sConfig = system:
|
|
|
|
{ hostname
|
|
|
|
, enableK3s ? true
|
|
|
|
, unlockMounts ? true
|
|
|
|
, mountVolumes ? true
|
|
|
|
, selfIp
|
|
|
|
, serverIp ? null
|
|
|
|
}:
|
2023-01-27 22:49:52 +00:00
|
|
|
let
|
|
|
|
device = "/dev/mapper/cryptdrive1";
|
2023-02-10 01:37:49 +00:00
|
|
|
device2 = "/dev/mapper/cryptdrive2";
|
2023-05-08 18:43:41 +00:00
|
|
|
subvolumes = [ "@k3s-config" ];
|
|
|
|
subvolumes2 = [ "@exports" "@garage" ];
|
2023-01-27 22:49:52 +00:00
|
|
|
in
|
2023-02-03 14:59:52 +00:00
|
|
|
makeGenericK3sConfig {
|
2023-02-11 04:47:38 +00:00
|
|
|
inherit hostname serverIp;
|
2023-02-03 14:59:52 +00:00
|
|
|
|
|
|
|
enableK3s = unlockMounts && mountVolumes && enableK3s;
|
2023-01-27 00:08:51 +00:00
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
extraModules = sd-images.packages.${system}.SoQuartzBlade.modules ++ [
|
2023-05-08 18:43:41 +00:00
|
|
|
(networkModule { inherit selfIp; })
|
2023-01-27 05:35:19 +00:00
|
|
|
(btrbkModule {
|
2023-02-10 01:37:49 +00:00
|
|
|
instances = [
|
|
|
|
{
|
|
|
|
inherit subvolumes;
|
|
|
|
mountDir = "/btrfs/nvme";
|
|
|
|
primaryIp = serverIp;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
subvolumes = subvolumes2;
|
|
|
|
mountDir = "/btrfs/nvme2";
|
|
|
|
name = "nvme2";
|
|
|
|
}
|
|
|
|
];
|
2023-01-27 05:35:19 +00:00
|
|
|
})
|
2023-01-27 22:49:52 +00:00
|
|
|
(if unlockMounts && mountVolumes then
|
2023-05-08 18:43:41 +00:00
|
|
|
(subvolumesModule { inherit device subvolumes; })
|
|
|
|
else
|
|
|
|
{ })
|
2023-03-04 00:49:00 +00:00
|
|
|
({ config, lib, pkgs, ... }:
|
2023-01-27 21:21:33 +00:00
|
|
|
let
|
|
|
|
keyFilePath = config.sops.secrets.k3sKeyFile.path;
|
|
|
|
prepareNvme = ''
|
|
|
|
#!/usr/bin/env bash
|
2023-01-27 07:19:05 +00:00
|
|
|
|
2023-01-27 21:21:33 +00:00
|
|
|
set -e
|
2023-01-27 05:35:19 +00:00
|
|
|
|
2023-07-11 04:07:14 +00:00
|
|
|
fallocate -l 4G /swapfile
|
|
|
|
chmod 0600 /swapfile
|
|
|
|
mkswap /swapfile
|
|
|
|
|
2023-01-27 21:21:33 +00:00
|
|
|
echo "Creating two partitions"
|
|
|
|
fdisk -w always /dev/nvme0n1 << EOL
|
|
|
|
g
|
|
|
|
n
|
|
|
|
1
|
|
|
|
|
|
|
|
+50G
|
|
|
|
n
|
|
|
|
2
|
|
|
|
|
|
|
|
|
|
|
|
w
|
|
|
|
EOL
|
|
|
|
|
2023-02-10 01:37:49 +00:00
|
|
|
echo "configure first part"
|
|
|
|
|
2023-01-27 21:21:33 +00:00
|
|
|
echo "YES" | cryptsetup luksFormat /dev/nvme0n1p1 -d ${keyFilePath}
|
|
|
|
cryptsetup luksOpen /dev/nvme0n1p1 cryptdrive1 -d ${keyFilePath}
|
|
|
|
|
|
|
|
mkfs.btrfs /dev/mapper/cryptdrive1
|
|
|
|
|
|
|
|
mkdir -p /btrfs/nvme
|
|
|
|
mount /dev/mapper/cryptdrive1 /btrfs/nvme
|
|
|
|
|
|
|
|
btrfs subvolume create /btrfs/nvme/@k3s-config
|
|
|
|
btrfs subvolume create /btrfs/nvme/@snapshots
|
2023-02-05 16:37:49 +00:00
|
|
|
btrfs subvolume create /btrfs/nvme/@swap
|
2023-01-27 21:21:33 +00:00
|
|
|
btrfs subvolume create /btrfs/nvme/@var-lib-rancher
|
|
|
|
btrfs subvolume create /btrfs/nvme/@var-log-pods
|
|
|
|
|
|
|
|
umount /btrfs/nvme
|
|
|
|
|
|
|
|
cryptsetup luksClose cryptdrive1
|
2023-02-10 01:37:49 +00:00
|
|
|
|
|
|
|
echo "configure second part"
|
|
|
|
|
|
|
|
echo "YES" | cryptsetup luksFormat /dev/nvme0n1p2 -d ${keyFilePath}
|
|
|
|
cryptsetup luksOpen /dev/nvme0n1p2 cryptdrive2 -d ${keyFilePath}
|
|
|
|
|
|
|
|
mkfs.btrfs /dev/mapper/cryptdrive2
|
|
|
|
|
|
|
|
mkdir -p /btrfs/nvme2
|
|
|
|
mount /dev/mapper/cryptdrive2 /btrfs/nvme2
|
|
|
|
|
|
|
|
btrfs subvolume create /btrfs/nvme2/@exports
|
2023-02-20 20:27:22 +00:00
|
|
|
btrfs subvolume create /btrfs/nvme2/@garage
|
2023-02-10 01:37:49 +00:00
|
|
|
btrfs subvolume create /btrfs/nvme2/@snapshots
|
|
|
|
|
|
|
|
umount /btrfs/nvme2
|
|
|
|
|
|
|
|
cryptsetup luksClose cryptdrive2
|
2023-01-27 05:35:19 +00:00
|
|
|
'';
|
2023-01-27 21:21:33 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
sops.secrets.k3sKeyFile = {
|
|
|
|
format = "binary";
|
|
|
|
sopsFile = ./secrets/k3sKeyFile.bin;
|
|
|
|
};
|
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
environment.systemPackages = with pkgs;
|
|
|
|
[ (writeShellScriptBin "prepare-nvme" prepareNvme) ];
|
2023-01-27 21:21:33 +00:00
|
|
|
|
|
|
|
environment.etc.crypttab = {
|
|
|
|
enable = unlockMounts;
|
|
|
|
text = ''
|
|
|
|
cryptdrive1 /dev/nvme0n1p1 ${keyFilePath} luks
|
2023-02-10 01:37:49 +00:00
|
|
|
cryptdrive2 /dev/nvme0n1p2 ${keyFilePath} luks
|
2023-01-27 21:21:33 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
fileSystems =
|
|
|
|
let
|
|
|
|
defaultOptions = [ "defaults" "rw" "compress=zstd" ];
|
2023-05-08 18:43:41 +00:00
|
|
|
fileSystemConfig = {
|
|
|
|
"/btrfs/nvme" = {
|
|
|
|
inherit device;
|
|
|
|
fsType = "btrfs";
|
|
|
|
options = defaultOptions;
|
|
|
|
};
|
|
|
|
"/btrfs/nvme2" = {
|
|
|
|
device = device2;
|
|
|
|
fsType = "btrfs";
|
|
|
|
options = defaultOptions;
|
|
|
|
};
|
|
|
|
"/exports" = {
|
|
|
|
device = device2;
|
|
|
|
fsType = "btrfs";
|
|
|
|
options = defaultOptions ++ [ "subvol=@exports" ];
|
|
|
|
};
|
|
|
|
"/garage" = {
|
|
|
|
device = device2;
|
|
|
|
fsType = "btrfs";
|
|
|
|
options = defaultOptions ++ [ "subvol=@garage" ];
|
2023-01-27 20:24:35 +00:00
|
|
|
};
|
2023-05-08 18:43:41 +00:00
|
|
|
"/swap" = {
|
|
|
|
inherit device;
|
|
|
|
fsType = "btrfs";
|
|
|
|
options = defaultOptions ++ [ "subvol=@swap" ];
|
|
|
|
};
|
|
|
|
"/var/lib/rancher" = {
|
|
|
|
inherit device;
|
|
|
|
fsType = "btrfs";
|
|
|
|
options = defaultOptions ++ [ "subvol=@var-lib-rancher" ];
|
|
|
|
};
|
|
|
|
"/var/log/pods" = {
|
|
|
|
inherit device;
|
|
|
|
fsType = "btrfs";
|
|
|
|
options = defaultOptions ++ [ "subvol=@var-log-pods" ];
|
|
|
|
};
|
|
|
|
};
|
2023-01-27 21:21:33 +00:00
|
|
|
in
|
|
|
|
if unlockMounts && mountVolumes then
|
2023-03-11 04:26:21 +00:00
|
|
|
fileSystemConfig
|
2023-01-27 21:21:33 +00:00
|
|
|
else
|
|
|
|
{ };
|
2023-02-05 16:37:49 +00:00
|
|
|
|
|
|
|
swapDevices =
|
|
|
|
let
|
|
|
|
swapFile = {
|
2023-07-11 04:07:14 +00:00
|
|
|
device = "/swapfile";
|
2023-02-05 16:37:49 +00:00
|
|
|
size = (1024 * 4);
|
|
|
|
};
|
|
|
|
in
|
2023-05-08 18:43:41 +00:00
|
|
|
if unlockMounts && mountVolumes then [ swapFile ] else [ ];
|
2023-02-10 01:37:49 +00:00
|
|
|
|
|
|
|
services.nfs.server = {
|
|
|
|
enable = unlockMounts && mountVolumes;
|
|
|
|
exports = ''
|
|
|
|
/exports 192.168.20.0/24(rw,sync,fsid=0,no_subtree_check)
|
|
|
|
/exports/k3s 192.168.20.0/24(rw,nohide,insecure,sync,no_subtree_check,no_root_squash)
|
|
|
|
'';
|
|
|
|
};
|
2023-01-27 21:21:33 +00:00
|
|
|
})
|
2023-01-27 00:08:51 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
makeSoQuartzK3sConfig = system:
|
|
|
|
{ hostname
|
|
|
|
, enableK3s ? true
|
|
|
|
, unlockMounts ? true
|
|
|
|
, mountVolumes ? true
|
|
|
|
, selfIp
|
|
|
|
, serverIp ? null
|
|
|
|
}:
|
2023-03-14 03:21:55 +00:00
|
|
|
let
|
|
|
|
device = "/dev/mapper/cryptdrive1";
|
2023-05-08 18:43:41 +00:00
|
|
|
subvolumes = [ "@k3s-config" ];
|
|
|
|
subvolumes2 = [ "@exports" "@garage" ];
|
2023-03-14 03:21:55 +00:00
|
|
|
in
|
|
|
|
makeGenericK3sConfig {
|
|
|
|
inherit hostname serverIp;
|
|
|
|
|
|
|
|
enableK3s = unlockMounts && mountVolumes && enableK3s;
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
extraModules = sd-images.packages.${system}.SoQuartzBlade.modules ++ [
|
2023-05-08 18:43:41 +00:00
|
|
|
(networkModule { inherit selfIp; })
|
2023-03-14 03:21:55 +00:00
|
|
|
(btrbkModule {
|
|
|
|
instances = [
|
|
|
|
{
|
|
|
|
inherit subvolumes;
|
|
|
|
mountDir = "/btrfs/nvme";
|
|
|
|
primaryIp = serverIp;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
subvolumes = subvolumes2;
|
|
|
|
mountDir = "/btrfs/nvme";
|
|
|
|
name = "nvme";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
})
|
|
|
|
(if unlockMounts && mountVolumes then
|
2023-05-08 18:43:41 +00:00
|
|
|
(subvolumesModule { inherit device subvolumes; })
|
|
|
|
else
|
|
|
|
{ })
|
2023-03-14 03:21:55 +00:00
|
|
|
({ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
keyFilePath = config.sops.secrets.k3sKeyFile.path;
|
|
|
|
prepareNvme = ''
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2023-07-11 04:07:14 +00:00
|
|
|
fallocate -l 4G /swapfile
|
|
|
|
chmod 0600 /swapfile
|
|
|
|
mkswap /swapfile
|
|
|
|
|
2023-03-14 03:21:55 +00:00
|
|
|
echo "YES" | cryptsetup luksFormat /dev/nvme0n1 -d ${keyFilePath}
|
|
|
|
cryptsetup luksOpen /dev/nvme0n1 cryptdrive1 -d ${keyFilePath}
|
|
|
|
|
|
|
|
mkfs.btrfs /dev/mapper/cryptdrive1
|
|
|
|
|
|
|
|
mkdir -p /btrfs/nvme
|
|
|
|
mount /dev/mapper/cryptdrive1 /btrfs/nvme
|
|
|
|
|
|
|
|
btrfs subvolume create /btrfs/nvme/@exports
|
|
|
|
btrfs subvolume create /btrfs/nvme/@garage
|
|
|
|
btrfs subvolume create /btrfs/nvme/@k3s-config
|
|
|
|
btrfs subvolume create /btrfs/nvme/@snapshots
|
|
|
|
btrfs subvolume create /btrfs/nvme/@swap
|
|
|
|
btrfs subvolume create /btrfs/nvme/@var-lib-rancher
|
|
|
|
btrfs subvolume create /btrfs/nvme/@var-log-pods
|
|
|
|
|
|
|
|
umount /btrfs/nvme
|
|
|
|
|
|
|
|
cryptsetup luksClose cryptdrive1
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
|
|
|
sops.secrets.k3sKeyFile = {
|
|
|
|
format = "binary";
|
|
|
|
sopsFile = ./secrets/k3sKeyFile.bin;
|
|
|
|
};
|
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
environment.systemPackages = with pkgs;
|
|
|
|
[ (writeShellScriptBin "prepare-nvme" prepareNvme) ];
|
2023-03-14 03:21:55 +00:00
|
|
|
|
|
|
|
environment.etc.crypttab = {
|
|
|
|
enable = unlockMounts;
|
|
|
|
text = ''
|
|
|
|
cryptdrive1 /dev/nvme0n1 ${keyFilePath} luks
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
fileSystems =
|
|
|
|
let
|
|
|
|
defaultOptions = [ "defaults" "rw" "compress=zstd" ];
|
2023-05-08 18:43:41 +00:00
|
|
|
fileSystemConfig = {
|
|
|
|
"/btrfs/nvme" = {
|
|
|
|
inherit device;
|
|
|
|
fsType = "btrfs";
|
|
|
|
options = defaultOptions;
|
|
|
|
};
|
|
|
|
"/exports" = {
|
|
|
|
device = device;
|
|
|
|
fsType = "btrfs";
|
|
|
|
options = defaultOptions ++ [ "subvol=@exports" ];
|
|
|
|
};
|
|
|
|
"/garage" = {
|
|
|
|
device = device;
|
|
|
|
fsType = "btrfs";
|
|
|
|
options = defaultOptions ++ [ "subvol=@garage" ];
|
|
|
|
};
|
|
|
|
"/swap" = {
|
|
|
|
inherit device;
|
|
|
|
fsType = "btrfs";
|
|
|
|
options = defaultOptions ++ [ "subvol=@swap" ];
|
|
|
|
};
|
|
|
|
"/var/lib/rancher" = {
|
|
|
|
inherit device;
|
|
|
|
fsType = "btrfs";
|
|
|
|
options = defaultOptions ++ [ "subvol=@var-lib-rancher" ];
|
|
|
|
};
|
|
|
|
"/var/log/pods" = {
|
|
|
|
inherit device;
|
|
|
|
fsType = "btrfs";
|
|
|
|
options = defaultOptions ++ [ "subvol=@var-log-pods" ];
|
2023-03-14 03:21:55 +00:00
|
|
|
};
|
2023-05-08 18:43:41 +00:00
|
|
|
};
|
2023-03-14 03:21:55 +00:00
|
|
|
in
|
|
|
|
if unlockMounts && mountVolumes then
|
|
|
|
fileSystemConfig
|
|
|
|
else
|
|
|
|
{ };
|
|
|
|
|
|
|
|
swapDevices =
|
|
|
|
let
|
|
|
|
swapFile = {
|
2023-07-11 04:07:14 +00:00
|
|
|
device = "/swapfile";
|
2023-03-14 03:21:55 +00:00
|
|
|
size = (1024 * 4);
|
|
|
|
};
|
|
|
|
in
|
2023-05-08 18:43:41 +00:00
|
|
|
if unlockMounts && mountVolumes then [ swapFile ] else [ ];
|
2023-03-14 03:21:55 +00:00
|
|
|
|
|
|
|
services.nfs.server = {
|
|
|
|
enable = unlockMounts && mountVolumes;
|
|
|
|
exports = ''
|
|
|
|
/exports 192.168.20.0/24(rw,sync,fsid=0,no_subtree_check)
|
|
|
|
/exports/k3s 192.168.20.0/24(rw,nohide,insecure,sync,no_subtree_check,no_root_squash)
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
makeBuildConfig = system:
|
|
|
|
{ hostname, macAddress ? null, selfIp }:
|
2023-02-11 04:47:38 +00:00
|
|
|
let
|
|
|
|
device = "/btrfs.4G";
|
|
|
|
mountDir = "/btrfs/loop";
|
2023-05-08 18:43:41 +00:00
|
|
|
subvolumes = [ "@build-cfg" ];
|
2023-02-11 04:47:38 +00:00
|
|
|
in
|
2023-06-07 23:10:43 +00:00
|
|
|
makeServerConfig {
|
2023-02-11 04:47:38 +00:00
|
|
|
inherit hostname;
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
extraModules = sd-images.packages.${system}.RockPro64v2.modules ++ [
|
2023-02-11 04:47:38 +00:00
|
|
|
dockerModule
|
|
|
|
(networkModule { inherit macAddress selfIp; })
|
2023-05-08 18:43:41 +00:00
|
|
|
(btrbkModule { instances = [{ inherit mountDir subvolumes; }]; })
|
|
|
|
(subvolumesModule { inherit device subvolumes; })
|
2023-03-04 00:49:00 +00:00
|
|
|
({ lib, ... }: {
|
2023-03-11 04:26:21 +00:00
|
|
|
fileSystems = {
|
2023-03-04 03:08:13 +00:00
|
|
|
"${mountDir}" = {
|
|
|
|
inherit device;
|
|
|
|
fsType = "btrfs";
|
|
|
|
options = [ "defaults" "compress=zstd" "rw" "loop" ];
|
|
|
|
};
|
2023-02-11 04:47:38 +00:00
|
|
|
};
|
2023-03-04 00:49:00 +00:00
|
|
|
})
|
2023-02-11 04:47:38 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2023-05-18 21:44:07 +00:00
|
|
|
makeBoardBackupConfig = modules: system:
|
2023-05-08 18:43:41 +00:00
|
|
|
{ hostname
|
|
|
|
, selfIp
|
|
|
|
, unlockMounts ? true
|
|
|
|
, mountVolumes ? true
|
2023-05-14 16:34:10 +00:00
|
|
|
, enableBackups ? true
|
2023-05-08 18:43:41 +00:00
|
|
|
, backupHosts ? [ ]
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
deviceLabel = "RAID";
|
|
|
|
device = "/dev/disk/by-label/${deviceLabel}";
|
|
|
|
mountDir = "/btrfs/raid";
|
|
|
|
in
|
2023-06-07 23:10:43 +00:00
|
|
|
makeServerConfig {
|
2023-05-06 19:22:29 +00:00
|
|
|
inherit hostname;
|
|
|
|
|
2023-05-18 21:44:07 +00:00
|
|
|
extraModules = modules ++ [
|
2023-05-06 19:22:29 +00:00
|
|
|
(networkModule { inherit selfIp; })
|
|
|
|
(btrbkModule {
|
2023-05-08 18:43:41 +00:00
|
|
|
instances = backupHosts;
|
|
|
|
localMountDir = mountDir;
|
2023-05-14 16:34:10 +00:00
|
|
|
enabled = unlockMounts && mountVolumes && enableBackups;
|
2023-05-06 19:22:29 +00:00
|
|
|
})
|
2023-05-08 18:43:41 +00:00
|
|
|
({ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
keyFile = "backupKeyFile";
|
|
|
|
keyFilePath = config.sops.secrets."${keyFile}".path;
|
|
|
|
dryRun = ''
|
|
|
|
for conf in $(ls /etc/btrbk); do
|
|
|
|
btrbk -c /etc/btrbk/$conf dryrun
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
prepareDrives = ''
|
2023-07-08 03:07:21 +00:00
|
|
|
for drive in "$1" "$2"; do
|
2023-05-08 18:43:41 +00:00
|
|
|
if [ "$drive" == "" ]; then
|
2023-07-08 03:07:21 +00:00
|
|
|
echo "Must provide 2 drives"
|
2023-05-08 18:43:41 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
2023-05-06 19:22:29 +00:00
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
drive_num=1
|
2023-07-08 03:07:21 +00:00
|
|
|
for drive in "$1" "$2"; do
|
|
|
|
echo "YES" | cryptsetup luksFormat $drive -d ${keyFilePath} --label="DATA$drive_num"
|
|
|
|
cryptsetup luksOpen "$drive" "cryptdrive$drive_num" -d ${keyFilePath}
|
2023-05-08 18:43:41 +00:00
|
|
|
drive_num=$((drive_num+1))
|
|
|
|
done
|
2023-05-06 19:22:29 +00:00
|
|
|
|
2023-07-08 03:07:21 +00:00
|
|
|
mkfs.btrfs -L ${deviceLabel} -d raid1 /dev/mapper/cryptdrive1 /dev/mapper/cryptdrive2
|
2023-05-06 19:22:29 +00:00
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
mkdir -p ${mountDir}
|
2023-05-06 19:22:29 +00:00
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
mount ${device} ${mountDir}
|
2023-05-06 19:22:29 +00:00
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
btrfs subvolume create ${mountDir}/@snapshots
|
2023-05-06 19:22:29 +00:00
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
umount ${mountDir}
|
2023-05-06 19:22:29 +00:00
|
|
|
|
2023-07-08 03:07:21 +00:00
|
|
|
for drive_num in {1..2}; do
|
2023-05-08 18:43:41 +00:00
|
|
|
cryptsetup luksClose "cryptdrive$drive_num"
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
|
|
|
sops.secrets."${keyFile}" = {
|
|
|
|
format = "binary";
|
|
|
|
sopsFile = ./secrets/${keyFile}.bin;
|
|
|
|
};
|
2023-05-06 19:22:29 +00:00
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
environment.systemPackages = with pkgs; [
|
2023-05-06 19:22:29 +00:00
|
|
|
(writeShellScriptBin "prepare-drives" prepareDrives)
|
|
|
|
(writeShellScriptBin "btrbk-dryrun" dryRun)
|
2023-05-08 18:43:41 +00:00
|
|
|
];
|
2023-05-06 19:22:29 +00:00
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
environment.etc.crypttab = {
|
|
|
|
enable = unlockMounts;
|
|
|
|
text = ''
|
2023-07-08 03:07:21 +00:00
|
|
|
cryptdrive1 /dev/disk/by-label/DATA1 ${keyFilePath} luks
|
|
|
|
cryptdrive2 /dev/disk/by-label/DATA2 ${keyFilePath} luks
|
2023-05-08 18:43:41 +00:00
|
|
|
'';
|
|
|
|
};
|
2023-05-06 19:22:29 +00:00
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
fileSystems =
|
|
|
|
let
|
|
|
|
filesystemConfig = {
|
|
|
|
"${mountDir}" = {
|
|
|
|
inherit device;
|
|
|
|
fsType = "btrfs";
|
2023-07-08 03:07:21 +00:00
|
|
|
options = [ "defaults" "compress=zstd" "rw" ];
|
2023-05-08 18:43:41 +00:00
|
|
|
};
|
2023-05-06 19:22:29 +00:00
|
|
|
};
|
2023-05-08 18:43:41 +00:00
|
|
|
in
|
|
|
|
if unlockMounts && mountVolumes then
|
|
|
|
filesystemConfig
|
|
|
|
else
|
|
|
|
{ };
|
|
|
|
})
|
2023-05-06 19:22:29 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2023-05-18 21:44:07 +00:00
|
|
|
makeRockPro64BackupConfig = makeBoardBackupConfig sd-images.packages.${system}.RockPro64v2.modules;
|
|
|
|
makeQuartz64ABackupConfig = makeBoardBackupConfig sd-images.packages.${system}.Quartz64A.modules;
|
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
makePostgresConfig = system:
|
|
|
|
{ hostname, selfIp, macAddress, keyFile, primaryIp ? null }:
|
2023-01-26 18:02:00 +00:00
|
|
|
let
|
2023-01-27 00:08:51 +00:00
|
|
|
device = "/dev/mapper/cryptdrive1";
|
2023-01-26 18:02:00 +00:00
|
|
|
mountDir = "/btrfs/ssd";
|
2023-05-08 18:43:41 +00:00
|
|
|
subvolumes = [ "@postgres" "@postgres-cfg" ];
|
2023-01-26 18:02:00 +00:00
|
|
|
in
|
2023-06-07 23:10:43 +00:00
|
|
|
makeServerConfig {
|
2023-01-26 18:02:00 +00:00
|
|
|
inherit hostname;
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
extraModules = sd-images.packages.${system}.Rock64.modules ++ [
|
2023-01-27 00:08:51 +00:00
|
|
|
dockerModule
|
2023-02-11 04:47:38 +00:00
|
|
|
(networkModule { inherit macAddress selfIp; })
|
2023-01-26 18:02:00 +00:00
|
|
|
(btrbkModule {
|
2023-05-08 18:43:41 +00:00
|
|
|
instances = [{ inherit mountDir primaryIp subvolumes; }];
|
2023-01-26 18:02:00 +00:00
|
|
|
})
|
2023-01-27 00:08:51 +00:00
|
|
|
(if primaryIp == null then
|
2023-05-08 18:43:41 +00:00
|
|
|
(subvolumesModule { inherit device subvolumes; })
|
|
|
|
else
|
|
|
|
{ })
|
2023-03-04 00:49:00 +00:00
|
|
|
({ config, lib, ... }:
|
2023-05-08 18:43:41 +00:00
|
|
|
let keyFilePath = config.sops.secrets."${keyFile}".path;
|
|
|
|
in {
|
2023-01-27 00:08:51 +00:00
|
|
|
sops.secrets.${keyFile} = {
|
|
|
|
format = "binary";
|
|
|
|
sopsFile = ./secrets/${keyFile}.bin;
|
|
|
|
};
|
|
|
|
|
2023-01-26 18:02:00 +00:00
|
|
|
environment.etc.crypttab = {
|
|
|
|
enable = true;
|
|
|
|
text = ''
|
|
|
|
cryptdrive1 /dev/sda1 ${keyFilePath} luks
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-03-11 04:26:21 +00:00
|
|
|
fileSystems = {
|
2023-03-04 03:08:13 +00:00
|
|
|
"${mountDir}" = {
|
|
|
|
inherit device;
|
|
|
|
fsType = "btrfs";
|
|
|
|
options = [ "defaults" "compress=zstd" "rw" ];
|
|
|
|
};
|
2023-01-26 18:02:00 +00:00
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
2023-04-21 19:36:45 +00:00
|
|
|
|
|
|
|
system = "x86_64-linux";
|
2023-01-25 04:55:24 +00:00
|
|
|
in
|
|
|
|
{
|
2023-01-26 18:02:00 +00:00
|
|
|
nixosConfigurations = {
|
2023-04-21 19:36:45 +00:00
|
|
|
redtail1 = makePostgresConfig system {
|
2023-01-25 05:08:04 +00:00
|
|
|
hostname = "redtail1";
|
2023-02-10 23:03:57 +00:00
|
|
|
selfIp = "192.168.20.23";
|
|
|
|
macAddress = "02:fe:30:d8:cf:64";
|
2023-01-26 18:02:00 +00:00
|
|
|
keyFile = "redtailKeyFile";
|
2023-06-28 18:37:29 +00:00
|
|
|
# primaryIp = "192.168.20.24";
|
2023-01-25 05:08:04 +00:00
|
|
|
};
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
redtail2 = makePostgresConfig system {
|
2023-01-25 05:08:04 +00:00
|
|
|
hostname = "redtail2";
|
2023-02-10 23:03:57 +00:00
|
|
|
selfIp = "192.168.20.24";
|
|
|
|
macAddress = "02:8a:70:2a:a8:5e";
|
2023-01-26 18:02:00 +00:00
|
|
|
keyFile = "redtailKeyFile";
|
2023-06-28 18:37:29 +00:00
|
|
|
primaryIp = "192.168.20.23";
|
2023-01-25 05:08:04 +00:00
|
|
|
};
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
whitestorm1 = makePostgresConfig system {
|
2023-01-25 05:08:04 +00:00
|
|
|
hostname = "whitestorm1";
|
2023-02-10 23:03:57 +00:00
|
|
|
selfIp = "192.168.20.26";
|
|
|
|
macAddress = "02:71:18:30:fc:0f";
|
2023-01-26 18:02:00 +00:00
|
|
|
keyFile = "whitestormKeyFile";
|
2023-02-10 23:03:57 +00:00
|
|
|
# primaryIp = "192.168.20.27";
|
2023-01-25 05:08:04 +00:00
|
|
|
};
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
whitestorm2 = makePostgresConfig system {
|
2023-01-25 05:08:04 +00:00
|
|
|
hostname = "whitestorm2";
|
2023-02-10 23:03:57 +00:00
|
|
|
selfIp = "192.168.20.27";
|
|
|
|
macAddress = "02:ff:ce:a9:d3:74";
|
2023-01-26 18:02:00 +00:00
|
|
|
keyFile = "whitestormKeyFile";
|
2023-02-10 23:08:05 +00:00
|
|
|
primaryIp = "192.168.20.11";
|
2023-01-25 05:08:04 +00:00
|
|
|
};
|
2023-01-27 00:08:51 +00:00
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
build2 = makeBuildConfig system {
|
2023-02-11 04:47:38 +00:00
|
|
|
hostname = "build2";
|
|
|
|
selfIp = "192.168.20.101";
|
|
|
|
};
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
k3s1 = makeOldSoQuartzK3sConfig system {
|
2023-01-27 00:08:51 +00:00
|
|
|
hostname = "k3s1";
|
2023-01-27 07:19:05 +00:00
|
|
|
selfIp = "192.168.20.120";
|
2023-01-27 00:08:51 +00:00
|
|
|
};
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
k3s2 = makeOldSoQuartzK3sConfig system {
|
2023-01-27 00:08:51 +00:00
|
|
|
hostname = "k3s2";
|
2023-01-27 07:19:05 +00:00
|
|
|
selfIp = "192.168.20.121";
|
2023-01-27 00:08:51 +00:00
|
|
|
serverIp = "192.168.20.120";
|
|
|
|
};
|
2023-02-03 14:59:52 +00:00
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
k3s3 = makeOldSoQuartzK3sConfig system {
|
2023-02-08 21:05:46 +00:00
|
|
|
hostname = "k3s3";
|
|
|
|
selfIp = "192.168.20.122";
|
|
|
|
serverIp = "192.168.20.120";
|
|
|
|
};
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
k3s4 = makeOldSoQuartzK3sConfig system {
|
2023-02-08 21:05:46 +00:00
|
|
|
hostname = "k3s4";
|
|
|
|
selfIp = "192.168.20.123";
|
|
|
|
serverIp = "192.168.20.120";
|
|
|
|
};
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
k3s5 = makeOldSoQuartzK3sConfig system {
|
2023-02-08 21:05:46 +00:00
|
|
|
hostname = "k3s5";
|
|
|
|
selfIp = "192.168.20.124";
|
|
|
|
serverIp = "192.168.20.120";
|
|
|
|
};
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
k3s6 = makeOldSoQuartzK3sConfig system {
|
2023-02-08 21:05:46 +00:00
|
|
|
hostname = "k3s6";
|
|
|
|
selfIp = "192.168.20.125";
|
|
|
|
serverIp = "192.168.20.120";
|
|
|
|
};
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
k3s7 = makeSoQuartzK3sConfig system {
|
2023-03-14 03:21:55 +00:00
|
|
|
hostname = "k3s7";
|
|
|
|
selfIp = "192.168.20.126";
|
|
|
|
serverIp = "192.168.20.120";
|
|
|
|
};
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
k3s8 = makeSoQuartzK3sConfig system {
|
2023-03-14 03:21:55 +00:00
|
|
|
hostname = "k3s8";
|
|
|
|
selfIp = "192.168.20.127";
|
|
|
|
serverIp = "192.168.20.120";
|
|
|
|
};
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
k3s9 = makeSoQuartzK3sConfig system {
|
|
|
|
hostname = "k3s9";
|
|
|
|
selfIp = "192.168.20.128";
|
|
|
|
serverIp = "192.168.20.120";
|
|
|
|
};
|
|
|
|
|
|
|
|
k3s10 = makeSoQuartzK3sConfig system {
|
|
|
|
hostname = "k3s10";
|
|
|
|
selfIp = "192.168.20.129";
|
|
|
|
serverIp = "192.168.20.120";
|
|
|
|
};
|
|
|
|
|
2023-06-30 00:25:13 +00:00
|
|
|
k3s11 = makeSoQuartzK3sConfig system {
|
|
|
|
hostname = "k3s11";
|
|
|
|
selfIp = "192.168.20.130";
|
|
|
|
serverIp = "192.168.20.120";
|
|
|
|
};
|
|
|
|
|
|
|
|
k3s12 = makeSoQuartzK3sConfig system {
|
|
|
|
hostname = "k3s12";
|
|
|
|
selfIp = "192.168.20.131";
|
|
|
|
serverIp = "192.168.20.120";
|
|
|
|
};
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
k3s-rock1 = makeRock64K3sConfig system {
|
2023-02-03 14:59:52 +00:00
|
|
|
hostname = "k3s-rock1";
|
2023-04-21 22:01:14 +00:00
|
|
|
selfIp = "192.168.20.110";
|
2023-02-03 18:09:17 +00:00
|
|
|
serverIp = "192.168.20.120";
|
2023-02-09 04:06:03 +00:00
|
|
|
macAddress = "02:36:51:19:8c:5d";
|
|
|
|
};
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
k3s-rock2 = makeRock64K3sConfig system {
|
2023-02-09 04:06:03 +00:00
|
|
|
hostname = "k3s-rock2";
|
|
|
|
selfIp = "192.168.20.111";
|
|
|
|
serverIp = "192.168.20.120";
|
|
|
|
macAddress = "02:af:fa:0e:c5:41";
|
|
|
|
};
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
k3s-rock3 = makeRock64K3sConfig system {
|
2023-02-09 04:06:03 +00:00
|
|
|
hostname = "k3s-rock3";
|
|
|
|
selfIp = "192.168.20.112";
|
|
|
|
serverIp = "192.168.20.120";
|
|
|
|
macAddress = "02:86:c1:62:77:51";
|
|
|
|
};
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
k3s-rock4 = makeRock64K3sConfig system {
|
2023-02-09 04:06:03 +00:00
|
|
|
hostname = "k3s-rock4";
|
|
|
|
selfIp = "192.168.20.113";
|
|
|
|
serverIp = "192.168.20.120";
|
|
|
|
macAddress = "02:7a:2e:2c:bb:99";
|
|
|
|
};
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
k3s-rock5 = makeRock64K3sConfig system {
|
2023-02-09 04:06:03 +00:00
|
|
|
hostname = "k3s-rock5";
|
|
|
|
selfIp = "192.168.20.114";
|
|
|
|
serverIp = "192.168.20.120";
|
|
|
|
macAddress = "02:76:67:0f:a0:b7";
|
2023-02-03 14:59:52 +00:00
|
|
|
};
|
2023-02-04 03:18:16 +00:00
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
k3s-rock6 = makeRock64K3sConfig system {
|
2023-02-19 19:17:23 +00:00
|
|
|
hostname = "k3s-rock6";
|
|
|
|
selfIp = "192.168.20.115";
|
|
|
|
serverIp = "192.168.20.120";
|
|
|
|
macAddress = "02:6b:c5:f0:d7:6d";
|
|
|
|
};
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
k3s-rock7 = makeRock64K3sConfig system {
|
2023-03-11 04:26:21 +00:00
|
|
|
hostname = "k3s-rock7";
|
|
|
|
selfIp = "192.168.20.116";
|
|
|
|
serverIp = "192.168.20.120";
|
|
|
|
macAddress = "02:5b:c4:cf:25:c2";
|
|
|
|
};
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
k3s-quartza1 = makeQuartz64AK3sConfig system {
|
2023-02-04 03:18:16 +00:00
|
|
|
hostname = "k3s-quartza1";
|
|
|
|
selfIp = "192.168.20.160";
|
|
|
|
serverIp = "192.168.20.120";
|
|
|
|
};
|
|
|
|
|
2023-04-21 19:36:45 +00:00
|
|
|
k3s-rockpro1 = makeRockPro64K3sConfig system {
|
2023-02-04 03:18:16 +00:00
|
|
|
hostname = "k3s-rockpro1";
|
|
|
|
selfIp = "192.168.20.180";
|
|
|
|
serverIp = "192.168.20.120";
|
|
|
|
};
|
2023-05-06 19:22:29 +00:00
|
|
|
|
2023-06-07 23:10:43 +00:00
|
|
|
pinetab2 = makeDesktopConfig {
|
2023-06-07 20:04:46 +00:00
|
|
|
hostname = "pinetab2";
|
|
|
|
extraModules = [
|
2023-06-14 23:31:11 +00:00
|
|
|
({ pkgs, ... }: {
|
2023-06-07 20:04:46 +00:00
|
|
|
sops.secrets.pinetabWireguardKey = {
|
|
|
|
format = "binary";
|
|
|
|
sopsFile = ./secrets/pinetabWireguardKey.bin;
|
|
|
|
};
|
2023-06-14 23:31:11 +00:00
|
|
|
})
|
2023-06-07 20:04:46 +00:00
|
|
|
({ config, ... }: wireguardModule {
|
|
|
|
address = "192.168.5.13/24";
|
|
|
|
privateKeyFile = config.sops.secrets.pinetabWireguardKey.path;
|
|
|
|
})
|
|
|
|
] ++ sd-images.packages.${system}.PineTab2.modules;
|
|
|
|
};
|
|
|
|
|
2023-05-18 21:44:07 +00:00
|
|
|
backup1 =
|
2023-05-08 18:43:41 +00:00
|
|
|
let
|
|
|
|
k3sMain = { ip, name }: {
|
|
|
|
inherit name;
|
|
|
|
primaryIp = ip;
|
|
|
|
mountDir = "/btrfs/nvme";
|
|
|
|
subvolumes = [ "@k3s-config" ];
|
|
|
|
};
|
2023-05-06 19:22:29 +00:00
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
k3sOld = { ip, name }: {
|
|
|
|
inherit name;
|
2023-05-06 19:22:29 +00:00
|
|
|
primaryIp = ip;
|
2023-05-08 18:43:41 +00:00
|
|
|
mountDir = "/btrfs/nvme2";
|
|
|
|
subvolumes = [ "@exports" "@garage" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
k3s = { ip, name }: {
|
|
|
|
inherit name;
|
2023-05-06 19:22:29 +00:00
|
|
|
primaryIp = ip;
|
2023-05-08 18:43:41 +00:00
|
|
|
mountDir = "/btrfs/nvme";
|
|
|
|
subvolumes = [ "@exports" "@garage" ];
|
|
|
|
};
|
2023-05-06 19:22:29 +00:00
|
|
|
|
2023-05-08 18:43:41 +00:00
|
|
|
db = { ip, name }: {
|
|
|
|
inherit name;
|
|
|
|
primaryIp = ip;
|
|
|
|
mountDir = "/btrfs/ssd";
|
|
|
|
subvolumes = [ "@postgres" "@postgres-cfg" ];
|
|
|
|
};
|
|
|
|
in
|
2023-05-18 21:44:07 +00:00
|
|
|
makeQuartz64ABackupConfig system {
|
|
|
|
hostname = "backup1";
|
2023-05-08 18:43:41 +00:00
|
|
|
selfIp = "192.168.20.190";
|
|
|
|
backupHosts = [
|
|
|
|
(k3sMain {
|
|
|
|
ip = "192.168.20.120";
|
|
|
|
name = "k3s1-config";
|
|
|
|
})
|
|
|
|
] ++ (builtins.map k3sOld [
|
|
|
|
{
|
|
|
|
ip = "192.168.20.120";
|
|
|
|
name = "k3s1";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
ip = "192.168.20.121";
|
|
|
|
name = "k3s2";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
ip = "192.168.20.122";
|
|
|
|
name = "k3s3";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
ip = "192.168.20.123";
|
|
|
|
name = "k3s4";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
ip = "192.168.20.124";
|
|
|
|
name = "k3s5";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
ip = "192.168.20.125";
|
|
|
|
name = "k3s6";
|
|
|
|
}
|
|
|
|
]) ++ (builtins.map k3s [
|
|
|
|
{
|
|
|
|
ip = "192.168.20.126";
|
|
|
|
name = "k3s7";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
ip = "192.168.20.127";
|
|
|
|
name = "k3s8";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
ip = "192.168.20.128";
|
|
|
|
name = "k3s9";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
ip = "192.168.20.129";
|
|
|
|
name = "k3s10";
|
|
|
|
}
|
2023-07-08 03:07:21 +00:00
|
|
|
{
|
|
|
|
ip = "192.168.20.130";
|
|
|
|
name = "k3s11";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
ip = "192.168.20.131";
|
|
|
|
name = "k3s12";
|
|
|
|
}
|
2023-05-08 18:43:41 +00:00
|
|
|
]) ++ (builtins.map db [
|
|
|
|
{
|
|
|
|
ip = "192.168.20.11";
|
|
|
|
name = "whitestorm1";
|
|
|
|
}
|
|
|
|
{
|
2023-07-08 03:07:21 +00:00
|
|
|
ip = "192.168.20.23";
|
|
|
|
name = "redtail1";
|
2023-05-08 18:43:41 +00:00
|
|
|
}
|
2023-05-06 19:22:29 +00:00
|
|
|
]);
|
2023-05-08 18:43:41 +00:00
|
|
|
};
|
2023-01-25 05:08:04 +00:00
|
|
|
};
|
2023-02-10 23:03:57 +00:00
|
|
|
|
2023-02-19 19:44:26 +00:00
|
|
|
deploy.nodes =
|
|
|
|
let
|
|
|
|
nodes = [
|
2023-05-08 18:43:41 +00:00
|
|
|
{
|
|
|
|
name = "redtail1";
|
|
|
|
ip = "192.168.20.23";
|
|
|
|
}
|
2023-06-28 18:37:29 +00:00
|
|
|
{
|
|
|
|
name = "redtail2";
|
|
|
|
ip = "192.168.20.24";
|
|
|
|
}
|
2023-05-08 18:43:41 +00:00
|
|
|
{
|
|
|
|
name = "whitestorm2";
|
|
|
|
ip = "192.168.20.27";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "build2";
|
|
|
|
ip = "192.168.20.101";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "k3s-rock1";
|
|
|
|
ip = "192.168.20.110";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "k3s-rock2";
|
|
|
|
ip = "192.168.20.111";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "k3s-rock3";
|
|
|
|
ip = "192.168.20.112";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "k3s-rock4";
|
|
|
|
ip = "192.168.20.113";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "k3s-rock5";
|
|
|
|
ip = "192.168.20.114";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "k3s-rock6";
|
|
|
|
ip = "192.168.20.115";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "k3s-rock7";
|
|
|
|
ip = "192.168.20.116";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "k3s1";
|
|
|
|
ip = "192.168.20.120";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "k3s2";
|
|
|
|
ip = "192.168.20.121";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "k3s3";
|
|
|
|
ip = "192.168.20.122";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "k3s4";
|
|
|
|
ip = "192.168.20.123";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "k3s5";
|
|
|
|
ip = "192.168.20.124";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "k3s6";
|
|
|
|
ip = "192.168.20.125";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "k3s7";
|
|
|
|
ip = "192.168.20.126";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "k3s8";
|
|
|
|
ip = "192.168.20.127";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "k3s9";
|
|
|
|
ip = "192.168.20.128";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "k3s10";
|
|
|
|
ip = "192.168.20.129";
|
|
|
|
}
|
2023-06-30 00:25:13 +00:00
|
|
|
{
|
|
|
|
name = "k3s11";
|
|
|
|
ip = "192.168.20.130";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "k3s12";
|
|
|
|
ip = "192.168.20.131";
|
|
|
|
}
|
2023-05-08 18:43:41 +00:00
|
|
|
{
|
|
|
|
name = "k3s-quartza1";
|
|
|
|
ip = "192.168.20.160";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "k3s-rockpro1";
|
|
|
|
ip = "192.168.20.180";
|
|
|
|
}
|
|
|
|
{
|
2023-05-18 21:44:07 +00:00
|
|
|
name = "backup1";
|
2023-05-08 18:43:41 +00:00
|
|
|
ip = "192.168.20.190";
|
|
|
|
}
|
2023-06-07 20:04:46 +00:00
|
|
|
{
|
|
|
|
name = "pinetab2";
|
|
|
|
ip = "192.168.5.13";
|
|
|
|
}
|
2023-02-19 19:44:26 +00:00
|
|
|
];
|
|
|
|
in
|
|
|
|
builtins.foldl'
|
2023-05-08 18:43:41 +00:00
|
|
|
(acc:
|
|
|
|
{ name, ip }:
|
|
|
|
acc // {
|
|
|
|
${name} = {
|
|
|
|
hostname = ip;
|
|
|
|
profiles.system = {
|
|
|
|
sshUser = "asonix";
|
|
|
|
user = "root";
|
|
|
|
magicRollback = false;
|
|
|
|
sshOpts = [ "-i" "/home/asonix/.ssh/kube-rsa" "-t" ];
|
|
|
|
path = deploy-rs.lib.aarch64-linux.activate.nixos
|
|
|
|
self.nixosConfigurations.${name};
|
|
|
|
};
|
2023-02-19 19:49:48 +00:00
|
|
|
};
|
2023-05-08 18:43:41 +00:00
|
|
|
})
|
2023-02-19 19:44:26 +00:00
|
|
|
{ }
|
|
|
|
nodes;
|
2023-05-08 18:43:41 +00:00
|
|
|
|
2023-05-08 18:45:05 +00:00
|
|
|
formatter.${system} = nixpkgs.legacyPackages.${system}.nixpkgs-fmt;
|
2023-01-25 01:58:10 +00:00
|
|
|
};
|
|
|
|
}
|