diff --git a/flake.nix b/flake.nix index 72a231d..d64e50e 100644 --- a/flake.nix +++ b/flake.nix @@ -93,6 +93,19 @@ } ]; + }; + pxe-boot = nixpkgs.lib.nixosSystem { + inherit system; + modules = [ + ./hosts/pxe-boot/configuration.nix + ./common/hardware-configuration.nix + home-manager.nixosModules.home-manager { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.nixos = import ./common/home.nix; + } + ]; + }; }; }; diff --git a/hosts/pxe-boot/configuration.nix b/hosts/pxe-boot/configuration.nix new file mode 100644 index 0000000..dee9a7c --- /dev/null +++ b/hosts/pxe-boot/configuration.nix @@ -0,0 +1,81 @@ +{ config, lib, pkgs, inputs, ... }: + +let + pxeRoot = "/srv/pxe"; + pxeBaseUrl = "http://pxe-boot"; + + menuIpxe = pkgs.writeText "menu.ipxe" '' + #!ipxe + + set base ${pxeBaseUrl} + + menu PXE Boot Menu + item nixos NixOS Installer + item rescue Rescue Environment + item shell iPXE Shell + item reboot Reboot + + choose target && goto ''${target} + + :nixos + kernel ''${base}/nixos/bzImage ip=dhcp + initrd ''${base}/nixos/initrd + boot + + :rescue + kernel ''${base}/rescue/vmlinuz ip=dhcp + initrd ''${base}/rescue/initrd + boot + + :shell + shell + + :reboot + reboot + ''; +in +{ + imports = + [ + ../../common/configuration.nix + ../../modules/nix/cache-client.nix + ../../modules/nix/remote-builder-client.nix + ]; + + networking.hostName = "pxe-boot"; + + environment.systemPackages = with pkgs; [ + ipxe + ]; + + services.nginx = { + enable = true; + + virtualHosts."pxe-boot" = { + default = true; + root = pxeRoot; + locations."/" = { + extraConfig = '' + autoindex on; + ''; + }; + }; + }; + + systemd.tmpfiles.rules = [ + "d ${pxeRoot} 0755 root root -" + "d ${pxeRoot}/boot 0755 root root -" + "d ${pxeRoot}/nixos 0755 root root -" + "d ${pxeRoot}/ubuntu 0755 root root -" + "d ${pxeRoot}/rescue 0755 root root -" + "C+ ${pxeRoot}/boot/menu.ipxe 0644 root root - ${menuIpxe}" + "C+ ${pxeRoot}/boot/ipxe.efi 0644 root root - ${pkgs.ipxe}/ipxe.efi" + "C+ ${pxeRoot}/boot/undionly.kpxe 0644 root root - ${pkgs.ipxe}/undionly.kpxe" + ]; + + services.openssh.settings.PermitRootLogin = "yes"; + + networking.firewall.allowedTCPPorts = [ 80 ]; + + system.stateVersion = "25.05"; +}