bootable targets: drive, pxe
This commit is contained in:
parent
2d4cf0b147
commit
9c0e1c011a
11 changed files with 88 additions and 64 deletions
9
bootable/common.nix
Normal file
9
bootable/common.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
boot = {
|
||||
initrd.systemd.tpm2.enable = false;
|
||||
loader.timeout = 0;
|
||||
};
|
||||
imports = [ ../common.nix ];
|
||||
services.getty.autologinUser = "root";
|
||||
systemd.tpm2.enable = false;
|
||||
}
|
||||
12
bootable/drive.nix
Normal file
12
bootable/drive.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
fileSystems = {
|
||||
"/".device = "/dev/disk/by-label/bootdrive-root";
|
||||
"/boot".device = "/dev/disk/by-label/bootdrive-esp";
|
||||
};
|
||||
hardware.enableAllHardware = true;
|
||||
imports = [
|
||||
../mods/fs.nix
|
||||
./common.nix
|
||||
];
|
||||
networking.hostName = "nixos-bootdrive";
|
||||
}
|
||||
|
|
@ -195,4 +195,4 @@
|
|||
"xilinx_emaclite"
|
||||
"xirc2ps_cs"
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -11,11 +11,9 @@
|
|||
device = "10.2.0.1:/";
|
||||
fsType = "nfs4";
|
||||
};
|
||||
hardware.enableAllHardware = true;
|
||||
imports = [
|
||||
../common.nix
|
||||
./common.nix
|
||||
./ethernet.nix
|
||||
];
|
||||
networking.hostName = "nixos-pxeboot";
|
||||
services.getty.autologinUser = "root";
|
||||
networking.hostName = "nixos-bootpxe";
|
||||
}
|
||||
|
|
@ -13,20 +13,7 @@
|
|||
kernelModules = [ "kvm-amd" ];
|
||||
kernelParams = [ "ttm.pages_limit=3014656" ];
|
||||
};
|
||||
fileSystems = {
|
||||
"/" = {
|
||||
device = "/dev/mapper/root";
|
||||
fsType = "ext4";
|
||||
};
|
||||
"/boot" = {
|
||||
device = "/dev/disk/by-uuid/2610-A769";
|
||||
fsType = "vfat";
|
||||
options = [
|
||||
"dmask=0077"
|
||||
"fmask=0077"
|
||||
];
|
||||
};
|
||||
};
|
||||
fileSystems."/boot".device = "/dev/disk/by-uuid/2610-A769";
|
||||
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
swapDevices = [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
{
|
||||
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-tree;
|
||||
nixosConfigurations = {
|
||||
nixos-bootdrive = nixpkgs.lib.nixosSystem { modules = [ ./bootable/drive.nix ]; };
|
||||
nixos-bootpxe = nixpkgs.lib.nixosSystem { modules = [ ./bootable/pxe.nix ]; };
|
||||
nixos-desktop = nixpkgs.lib.nixosSystem {
|
||||
modules = [
|
||||
./desktop/configuration.nix
|
||||
|
|
@ -38,7 +40,6 @@
|
|||
sops-nix.nixosModules.sops
|
||||
];
|
||||
};
|
||||
nixos-pxeboot = nixpkgs.lib.nixosSystem { modules = [ ./pxeboot/configuration.nix ]; };
|
||||
nixos-server = nixpkgs.lib.nixosSystem {
|
||||
modules = [
|
||||
./server/configuration.nix
|
||||
|
|
|
|||
13
install.sh
13
install.sh
|
|
@ -1,15 +1,12 @@
|
|||
gdisk $DISK
|
||||
mkfs.fat -F 32 $ESPPART
|
||||
mkfs.fat -F 32 -n $HOST-esp $ESPPART
|
||||
cryptsetup luksFormat $ROOTPART
|
||||
cryptsetup open $ROOTPART root
|
||||
mkfs.ext4 /dev/mapper/root
|
||||
mkfs.ext4 -L $HOST-root /dev/mapper/root
|
||||
mount /dev/mapper/root /mnt
|
||||
mount $ESPPART --mkdir -o umask=077 /mnt/boot
|
||||
mkdir -p /mnt/var/lib
|
||||
mkswap -F -s $SWAPSIZE /mnt/var/swapfile
|
||||
swapon /mnt/var/swapfile
|
||||
mount --mkdir $ESPPART /mnt/boot
|
||||
mkdir -p /mnt/var/lib
|
||||
# restore backup
|
||||
nixos-generate-config --root /mnt --show-hardware-config > /mnt/etc/nixos/$HOSTNAME/hardware.nix
|
||||
nixos-install --no-root-passwd --no-channel-copy --flake "/mnt/etc/nixos#nixos-$HOSTNAME"
|
||||
nixos-install --no-root-passwd --no-channel-copy --flake "/mnt/etc/nixos#nixos-$HOST"
|
||||
sbctl enroll-keys --yolo
|
||||
systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+2+7 $ROOTPART
|
||||
|
|
|
|||
15
mods/fs.nix
Normal file
15
mods/fs.nix
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
fileSystems = {
|
||||
"/" = {
|
||||
fsType = "ext4";
|
||||
options = [ "noatime" ];
|
||||
};
|
||||
"/boot" = {
|
||||
fsType = "vfat";
|
||||
options = [
|
||||
"noatime"
|
||||
"umask=0077"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -4,12 +4,10 @@
|
|||
kernelModules = [ "amneziawg" ];
|
||||
loader.limine.secureBoot.enable = true;
|
||||
};
|
||||
fileSystems = {
|
||||
"/".options = [ "noatime" ];
|
||||
"/boot".options = [ "noatime" ];
|
||||
};
|
||||
fileSystems."/".device = "/dev/mapper/root";
|
||||
imports = [
|
||||
../common.nix
|
||||
./fs.nix
|
||||
./pxeboot.nix
|
||||
./vps-init.nix
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
{ config, pkgs, ... }: {
|
||||
environment.systemPackages = [ pkgs.grub2_efi ];
|
||||
networking = {
|
||||
firewall = {
|
||||
allowedTCPPorts = [
|
||||
|
|
@ -30,6 +29,7 @@
|
|||
slave-ethernet.connection = {
|
||||
controller = "br0";
|
||||
id = "slave-ethernet";
|
||||
port-type = "bridge";
|
||||
type = "ethernet";
|
||||
};
|
||||
static-bridge = {
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
};
|
||||
services = {
|
||||
dnsmasq.settings = {
|
||||
bind-interfaces = true;
|
||||
bind-dynamic = true;
|
||||
dhcp-boot = "efi/boot/BOOTX64.EFI";
|
||||
dhcp-range = [
|
||||
"10.2.0.2,10.2.255.254,12h"
|
||||
|
|
@ -73,22 +73,42 @@
|
|||
};
|
||||
};
|
||||
systemd = {
|
||||
services.pxeboot = {
|
||||
path = with pkgs; [
|
||||
nix
|
||||
nixos-install
|
||||
util-linux
|
||||
];
|
||||
script = ''
|
||||
(printf '{\n boot.initrd.availableKernelModules = [\n'
|
||||
cd ${config.boot.kernelPackages.kernel.modules}/lib/modules/*/kernel/drivers/net/ethernet
|
||||
find -type f | sed 's/^.*\/\([^.]*\).*$/ "\1"/' | sort
|
||||
printf ' ];\n}') > /etc/nixos/pxeboot/ethernet.nix
|
||||
cd /srv/pxe
|
||||
nixos-install --flake "/etc/nixos#nixos-pxeboot" \
|
||||
--no-channel-copy --no-root-passwd --root $PWD/nixos
|
||||
mountpoint -q export || mount -B --mkdir nixos export
|
||||
'';
|
||||
services = {
|
||||
pxeboot = {
|
||||
before = [ "nfs-server.service" ];
|
||||
path = [ pkgs.util-linux ];
|
||||
preStop = ''
|
||||
cd /srv/pxe
|
||||
mountpoint -q export && umount export
|
||||
'';
|
||||
requiredBy = [ "nfs-server.service" ];
|
||||
script = ''
|
||||
cd /srv/pxe
|
||||
if [ ! -e export ]; then
|
||||
systemctl start pxeboot-install
|
||||
fi
|
||||
mountpoint -q export || mount -B --mkdir nixos export
|
||||
'';
|
||||
serviceConfig = {
|
||||
RemainAfterExit = true;
|
||||
Type = "oneshot";
|
||||
};
|
||||
};
|
||||
pxeboot-install = {
|
||||
path = with pkgs; [
|
||||
nix
|
||||
nixos-install
|
||||
];
|
||||
script = ''
|
||||
(printf '{\n boot.initrd.availableKernelModules = [\n'
|
||||
cd ${config.boot.kernelPackages.kernel.modules}/lib/modules/*/kernel/drivers/net/ethernet
|
||||
find -type f | sed 's/^.*\/\([^.]*\).*$/ "\1"/' | sort
|
||||
printf ' ];\n}') > /etc/nixos/pxeboot/ethernet.nix
|
||||
nixos-install --flake "/etc/nixos#nixos-pxeboot" \
|
||||
--no-channel-copy --no-root-passwd --root /srv/pxe/nixos
|
||||
'';
|
||||
# delete --no-channel-copy later
|
||||
};
|
||||
};
|
||||
tmpfiles.rules = [ "d /srv/pxe/nixos/boot" ];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,19 +15,6 @@
|
|||
"memmap=0x4000%0xbfb7a000-4"
|
||||
];
|
||||
};
|
||||
fileSystems = {
|
||||
"/" = {
|
||||
device = "/dev/mapper/root";
|
||||
fsType = "ext4";
|
||||
};
|
||||
"/boot" = {
|
||||
device = "/dev/disk/by-uuid/86F4-A8F1";
|
||||
fsType = "vfat";
|
||||
options = [
|
||||
"dmask=0077"
|
||||
"fmask=0077"
|
||||
];
|
||||
};
|
||||
};
|
||||
fileSystems."/boot".device = "/dev/disk/by-uuid/86F4-A8F1";
|
||||
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue