Add host pbx
This commit is contained in:
parent
1efde7694d
commit
4e65fd11a9
3 changed files with 187 additions and 0 deletions
5
hosts/default.nix
Normal file
5
hosts/default.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
_inputs: {
|
||||||
|
pbx = {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
};
|
||||||
|
}
|
||||||
62
hosts/pbx/configuration.nix
Normal file
62
hosts/pbx/configuration.nix
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
imports = [
|
||||||
|
./disko.nix
|
||||||
|
../../users/jalr
|
||||||
|
];
|
||||||
|
|
||||||
|
weinturm = {
|
||||||
|
impermanence = {
|
||||||
|
enable = true;
|
||||||
|
rootDevice = config.disko.devices.disk.disk1.content.partitions.nixos.device;
|
||||||
|
};
|
||||||
|
zram.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
networking = {
|
||||||
|
hostName = "pbx";
|
||||||
|
useDHCP = lib.mkDefault true;
|
||||||
|
};
|
||||||
|
|
||||||
|
boot = {
|
||||||
|
initrd = {
|
||||||
|
availableKernelModules = ["xhci_pci" "ehci_pci" "ahci" "usbhid" "usb_storage" "sd_mod"];
|
||||||
|
};
|
||||||
|
|
||||||
|
kernelModules = ["kvm-intel"];
|
||||||
|
kernelParams = [
|
||||||
|
"console=ttyS0,115200"
|
||||||
|
"console=tty1"
|
||||||
|
];
|
||||||
|
|
||||||
|
loader = {
|
||||||
|
efi = {
|
||||||
|
efiSysMountPoint = "/boot";
|
||||||
|
canTouchEfiVariables = false;
|
||||||
|
};
|
||||||
|
generationsDir.copyKernels = true;
|
||||||
|
grub = {
|
||||||
|
devices = ["/dev/sda"];
|
||||||
|
efiInstallAsRemovable = true;
|
||||||
|
copyKernels = true;
|
||||||
|
efiSupport = true;
|
||||||
|
mirroredBoots = [
|
||||||
|
{
|
||||||
|
path = "/boot1";
|
||||||
|
devices = ["/dev/sdb"];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
extraConfig = ''
|
||||||
|
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
|
||||||
|
terminal_input --append serial
|
||||||
|
terminal_output --append serial
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
system.stateVersion = "25.05"; # Did you read the comment?
|
||||||
|
}
|
||||||
120
hosts/pbx/disko.nix
Normal file
120
hosts/pbx/disko.nix
Normal file
|
|
@ -0,0 +1,120 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
cfg = config.disko;
|
||||||
|
mkEfiPartition = mountpoint: {
|
||||||
|
size = "1024M";
|
||||||
|
type = "EF00";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "vfat";
|
||||||
|
inherit mountpoint;
|
||||||
|
mountOptions = [
|
||||||
|
"uid=0"
|
||||||
|
"gid=0"
|
||||||
|
"fmask=0077"
|
||||||
|
"dmask=0077"
|
||||||
|
"nodev"
|
||||||
|
"nosuid"
|
||||||
|
"noexec"
|
||||||
|
"x-systemd.idle-timeout=1min"
|
||||||
|
"x-systemd.automount"
|
||||||
|
"noauto"
|
||||||
|
"nofail"
|
||||||
|
"noatime"
|
||||||
|
"X-mount.mkdir"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
label = "btrfs-raid1";
|
||||||
|
subvolumes = {
|
||||||
|
"/root" = {
|
||||||
|
mountpoint = "/";
|
||||||
|
mountOptions = ["degraded" "compress-force=zstd:1" "noatime"];
|
||||||
|
};
|
||||||
|
"/home" = {
|
||||||
|
mountpoint = "/home";
|
||||||
|
mountOptions = ["degraded" "compress-force=zstd:1" "noatime" "nodev" "nosuid"];
|
||||||
|
};
|
||||||
|
"/nix" = {
|
||||||
|
mountpoint = "/nix";
|
||||||
|
mountOptions = ["degraded" "compress-force=zstd:1" "noatime" "nodev"];
|
||||||
|
};
|
||||||
|
"/log" = {
|
||||||
|
mountpoint = "/var/log";
|
||||||
|
mountOptions = ["degraded" "compress-force=zstd:1" "noatime" "nodev" "nosuid"];
|
||||||
|
};
|
||||||
|
"/persist" = {
|
||||||
|
mountpoint = "/persist";
|
||||||
|
mountOptions = ["degraded" "compress-force=zstd:1" "noatime" "nodev" "nosuid"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
disko.devices = {
|
||||||
|
disk = {
|
||||||
|
disk1 = {
|
||||||
|
type = "disk";
|
||||||
|
device = "/dev/sda";
|
||||||
|
content = {
|
||||||
|
type = "gpt";
|
||||||
|
partitions = {
|
||||||
|
boot = {
|
||||||
|
size = "1M";
|
||||||
|
type = "EF02"; # for grub MBR
|
||||||
|
};
|
||||||
|
ESP = mkEfiPartition "/boot";
|
||||||
|
nixos = {
|
||||||
|
size = "100%";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
disk2 = {
|
||||||
|
type = "disk";
|
||||||
|
device = "/dev/sdb";
|
||||||
|
content = {
|
||||||
|
type = "gpt";
|
||||||
|
partitions = {
|
||||||
|
boot = {
|
||||||
|
size = "1M";
|
||||||
|
type = "EF02"; # for grub MBR
|
||||||
|
};
|
||||||
|
ESP = mkEfiPartition "/boot1";
|
||||||
|
nixos = {
|
||||||
|
size = "100%";
|
||||||
|
content = let
|
||||||
|
thisPartition = cfg.devices.disk.disk2.content.partitions.nixos.device;
|
||||||
|
mirror = cfg.devices.disk.disk1.content.partitions.nixos.device;
|
||||||
|
in {
|
||||||
|
type = "btrfs";
|
||||||
|
extraArgs = [
|
||||||
|
"-f"
|
||||||
|
"--label ${label}"
|
||||||
|
"-m raid1"
|
||||||
|
"-d raid1"
|
||||||
|
"${mirror}"
|
||||||
|
];
|
||||||
|
postCreateHook = ''
|
||||||
|
mountpoint="$(mktemp -d)"
|
||||||
|
mount "${thisPartition}" "$mountpoint" -o subvol=/ || mount "${mirror}" "$mountpoint" -o subvol=/
|
||||||
|
trap 'umount "$mountpoint"; rmdir "$mountpoint"' EXIT
|
||||||
|
btrfs subvolume snapshot -r $mountpoint/root $mountpoint/root-blank
|
||||||
|
'';
|
||||||
|
inherit subvolumes;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSystems = with lib.attrsets;
|
||||||
|
mapAttrs' (
|
||||||
|
_: value:
|
||||||
|
nameValuePair value.mountpoint {device = lib.mkForce "/dev/disk/by-label/${label}";}
|
||||||
|
)
|
||||||
|
subvolumes;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue