Archived
Rename PXE installer menu entry, add vanilla NixOS minimal netboot entry #31
@@ -150,7 +150,11 @@ use case.
|
|||||||
|
|
||||||
The `pxe` variant is also built automatically as part of the `pxe-boot` host
|
The `pxe` variant is also built automatically as part of the `pxe-boot` host
|
||||||
itself (`modules/pxe-boot/stage-installer-artifacts.nix`) and served over
|
itself (`modules/pxe-boot/stage-installer-artifacts.nix`) and served over
|
||||||
iPXE — see `docs/pxe-boot.md`.
|
iPXE as the menu's "NixOS Auto-Installer" entry — see `docs/pxe-boot.md`.
|
||||||
|
That same host also builds and serves `packages.x86_64-linux.pxe-minimal`,
|
||||||
|
a vanilla NixOS minimal netboot image with none of this auto-installer's
|
||||||
|
wiring, as a separate "NixOS Minimal" menu entry — also documented in
|
||||||
|
`docs/pxe-boot.md`, not covered further here since it's not this installer.
|
||||||
|
|
||||||
## Host keys
|
## Host keys
|
||||||
|
|
||||||
|
|||||||
+35
-16
@@ -1,9 +1,10 @@
|
|||||||
# pxe-boot
|
# pxe-boot
|
||||||
|
|
||||||
The `pxe-boot` host serves HTTP boot assets for iPXE clients — including a
|
The `pxe-boot` host serves HTTP boot assets for iPXE clients — including
|
||||||
self-staged copy of this flake's own auto-installer netboot image, see
|
self-staged copies of both this flake's own auto-installer netboot image
|
||||||
`docs/auto-installer.md` for what that image actually is and does once
|
(see `docs/auto-installer.md` for what that image actually is and does once
|
||||||
booted.
|
booted) and a vanilla, unmodified NixOS minimal netboot image for plain
|
||||||
|
rescue/inspection use.
|
||||||
|
|
||||||
## Host Role
|
## Host Role
|
||||||
|
|
||||||
@@ -28,7 +29,8 @@ The host creates these directories with systemd tmpfiles:
|
|||||||
/srv/pxe
|
/srv/pxe
|
||||||
/srv/pxe/http
|
/srv/pxe/http
|
||||||
/srv/pxe/http/images
|
/srv/pxe/http/images
|
||||||
/srv/pxe/http/nixos
|
/srv/pxe/http/auto-installer
|
||||||
|
/srv/pxe/http/nixos-minimal
|
||||||
/srv/pxe/http/systemrescue
|
/srv/pxe/http/systemrescue
|
||||||
/srv/pxe/http/ubuntu
|
/srv/pxe/http/ubuntu
|
||||||
/srv/pxe/http/rescue
|
/srv/pxe/http/rescue
|
||||||
@@ -37,7 +39,7 @@ The host creates these directories with systemd tmpfiles:
|
|||||||
|
|
||||||
Mount shared image storage under `/srv/pxe/http`, preferably
|
Mount shared image storage under `/srv/pxe/http`, preferably
|
||||||
`/srv/pxe/http/images` unless a menu entry expects files in a specific
|
`/srv/pxe/http/images` unless a menu entry expects files in a specific
|
||||||
directory such as `/srv/pxe/http/nixos`.
|
directory such as `/srv/pxe/http/auto-installer`.
|
||||||
|
|
||||||
The HTTP iPXE chain is:
|
The HTTP iPXE chain is:
|
||||||
|
|
||||||
@@ -50,20 +52,37 @@ undionly.kpxe or ipxe.efi
|
|||||||
|
|
||||||
The generated menu currently exposes entries for:
|
The generated menu currently exposes entries for:
|
||||||
|
|
||||||
- NixOS installer
|
- NixOS Auto-Installer
|
||||||
|
- NixOS Minimal
|
||||||
- SystemRescue environment
|
- SystemRescue environment
|
||||||
- iPXE shell
|
- iPXE shell
|
||||||
- Reboot
|
- Reboot
|
||||||
|
|
||||||
The NixOS installer entry chain-loads `/srv/pxe/http/nixos/netboot.ipxe`,
|
Both NixOS entries chain-load a `netboot.ipxe` staged into their own
|
||||||
which is nixpkgs' own generated netboot iPXE script (correct `init=`/`initrd=`
|
directory (`/srv/pxe/http/auto-installer/netboot.ipxe` and
|
||||||
kernel parameters included) rather than a hand-rolled boot line — that script
|
`/srv/pxe/http/nixos-minimal/netboot.ipxe`), each nixpkgs' own generated
|
||||||
in turn expects its kernel/initrd siblings in the same directory. All three
|
netboot iPXE script (correct `init=`/`initrd=` kernel parameters included)
|
||||||
files (`bzImage`, `initrd`, `netboot.ipxe`) are built from this flake's own
|
rather than a hand-rolled boot line — that script in turn expects its
|
||||||
`modules/installer/iso.nix` netboot image (the same one `nix build .#pxe`
|
kernel/initrd siblings in the same directory. Each directory's three files
|
||||||
produces) and staged automatically by
|
(`bzImage`, `initrd`, `netboot.ipxe`) are built from source and staged
|
||||||
`modules/pxe-boot/stage-installer-artifacts.nix` via `systemd.tmpfiles.rules`
|
automatically by `modules/pxe-boot/stage-installer-artifacts.nix` via
|
||||||
— no manual operator step required.
|
`systemd.tmpfiles.rules` — no manual operator step required:
|
||||||
|
|
||||||
|
- `auto-installer` is this flake's own `netbootSystem` (`flake.nix`) — the
|
||||||
|
same auto-installer image `nix build .#pxe` produces. See
|
||||||
|
`docs/auto-installer.md`.
|
||||||
|
- `nixos-minimal` is `netbootMinimalSystem` (`flake.nix`) — nixpkgs'
|
||||||
|
`netboot-minimal.nix` composed on its own, with none of this flake's
|
||||||
|
auto-installer wiring (no `common.nix`, no `auto-install.sh`, no baked
|
||||||
|
host keys or custom users). Same `nix build .#pxe-minimal` mechanism as
|
||||||
|
the auto-installer image, just a different module composition. Useful
|
||||||
|
as a plain rescue/inspection shell that doesn't assume anything about
|
||||||
|
this flake.
|
||||||
|
|
||||||
|
Both images set `networking.hostName` to match their menu entry/staged
|
||||||
|
directory name (`auto-installer` / `nixos-minimal`), so each one's
|
||||||
|
generated system name (`nixos-system-<name>-*`) is self-describing rather
|
||||||
|
than the nixpkgs default of `nixos-system-nixos-*` for both.
|
||||||
|
|
||||||
The SystemRescue entry expects the source ISO at:
|
The SystemRescue entry expects the source ISO at:
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@
|
|||||||
# file without a same-option circular dependency (a module
|
# file without a same-option circular dependency (a module
|
||||||
# contributing to environment.etc can't read the merged
|
# contributing to environment.etc can't read the merged
|
||||||
# environment.etc it's itself contributing to).
|
# environment.etc it's itself contributing to).
|
||||||
specialArgs = { inherit inputs vars netbootSystem flakeTarget; };
|
specialArgs = { inherit inputs vars netbootSystem netbootMinimalSystem flakeTarget; };
|
||||||
};
|
};
|
||||||
|
|
||||||
# Generated platform x build-type matrix. pxe-boot has no linode
|
# Generated platform x build-type matrix. pxe-boot has no linode
|
||||||
@@ -133,6 +133,12 @@
|
|||||||
# profiles/installation-device.nix independently, so common.nix's
|
# profiles/installation-device.nix independently, so common.nix's
|
||||||
# initialHashedPassword override (which assumes that profile is
|
# initialHashedPassword override (which assumes that profile is
|
||||||
# present) still applies correctly without iso.nix in the mix.
|
# present) still applies correctly without iso.nix in the mix.
|
||||||
|
#
|
||||||
|
# networking.hostName is set explicitly (rather than left at nixpkgs'
|
||||||
|
# own "nixos" default) so this image's generated system name
|
||||||
|
# (nixos-system-auto-installer-*) matches its iPXE menu entry —
|
||||||
|
# see modules/build-types/pxe-boot.nix's :auto-installer item — and
|
||||||
|
# its staged directory, /srv/pxe/http/auto-installer.
|
||||||
netbootSystem = nixpkgs.lib.nixosSystem {
|
netbootSystem = nixpkgs.lib.nixosSystem {
|
||||||
inherit system;
|
inherit system;
|
||||||
modules = [
|
modules = [
|
||||||
@@ -142,10 +148,32 @@
|
|||||||
(modulesPath + "/installer/netboot/netboot-minimal.nix")
|
(modulesPath + "/installer/netboot/netboot-minimal.nix")
|
||||||
];
|
];
|
||||||
})
|
})
|
||||||
|
{ networking.hostName = "auto-installer"; }
|
||||||
];
|
];
|
||||||
specialArgs = { inherit vars; };
|
specialArgs = { inherit vars; };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# A genuinely vanilla NixOS minimal netboot image: nixpkgs'
|
||||||
|
# netboot-minimal.nix on its own, with none of this flake's
|
||||||
|
# auto-installer wiring (no common.nix — no auto-install.sh, no
|
||||||
|
# baked host keys, no custom users/passwords). Built from source via
|
||||||
|
# the same nixosSystem + netboot-minimal.nix path as netbootSystem
|
||||||
|
# above, so both go through an identical build mechanism; the only
|
||||||
|
# difference is what's composed in. hostName again matches this
|
||||||
|
# image's iPXE menu entry (:nixos-minimal) and staged directory
|
||||||
|
# (/srv/pxe/http/nixos-minimal).
|
||||||
|
netbootMinimalSystem = nixpkgs.lib.nixosSystem {
|
||||||
|
inherit system;
|
||||||
|
modules = [
|
||||||
|
({ modulesPath, ... }: {
|
||||||
|
imports = [
|
||||||
|
(modulesPath + "/installer/netboot/netboot-minimal.nix")
|
||||||
|
];
|
||||||
|
})
|
||||||
|
{ networking.hostName = "nixos-minimal"; }
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -167,6 +195,15 @@
|
|||||||
{ name = "initrd"; path = netbootSystem.config.system.build.netbootRamdisk; }
|
{ name = "initrd"; path = netbootSystem.config.system.build.netbootRamdisk; }
|
||||||
{ name = "kernel"; path = netbootSystem.config.system.build.kernel; }
|
{ name = "kernel"; path = netbootSystem.config.system.build.kernel; }
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Vanilla NixOS minimal netboot bundle — see netbootMinimalSystem
|
||||||
|
# above. Staged onto the pxe-boot host alongside packages.pxe by
|
||||||
|
# modules/pxe-boot/stage-installer-artifacts.nix.
|
||||||
|
pxe-minimal = pkgs.linkFarm "pxe-minimal" [
|
||||||
|
{ name = "netboot.ipxe"; path = netbootMinimalSystem.config.system.build.netbootIpxeScript; }
|
||||||
|
{ name = "initrd"; path = netbootMinimalSystem.config.system.build.netbootRamdisk; }
|
||||||
|
{ name = "kernel"; path = netbootMinimalSystem.config.system.build.kernel; }
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,15 +68,19 @@ let
|
|||||||
set base ${pxeBaseUrl}
|
set base ${pxeBaseUrl}
|
||||||
|
|
||||||
menu PXE Boot Menu
|
menu PXE Boot Menu
|
||||||
item nixos NixOS Installer
|
item auto-installer NixOS Auto-Installer
|
||||||
|
item nixos-minimal NixOS Minimal
|
||||||
item rescue Rescue Environment
|
item rescue Rescue Environment
|
||||||
item shell iPXE Shell
|
item shell iPXE Shell
|
||||||
item reboot Reboot
|
item reboot Reboot
|
||||||
|
|
||||||
choose target && goto ''${target}
|
choose target && goto ''${target}
|
||||||
|
|
||||||
:nixos
|
:auto-installer
|
||||||
chain ''${base}/nixos/netboot.ipxe
|
chain ''${base}/auto-installer/netboot.ipxe
|
||||||
|
|
||||||
|
:nixos-minimal
|
||||||
|
chain ''${base}/nixos-minimal/netboot.ipxe
|
||||||
|
|
||||||
:rescue
|
:rescue
|
||||||
chain ''${base}/systemrescue.ipxe
|
chain ''${base}/systemrescue.ipxe
|
||||||
@@ -129,7 +133,8 @@ in
|
|||||||
"d ${pxeRoot} 0755 root root -"
|
"d ${pxeRoot} 0755 root root -"
|
||||||
"d ${httpRoot} 0755 root root -"
|
"d ${httpRoot} 0755 root root -"
|
||||||
"d ${httpRoot}/images 0755 root root -"
|
"d ${httpRoot}/images 0755 root root -"
|
||||||
"d ${httpRoot}/nixos 0755 root root -"
|
"d ${httpRoot}/auto-installer 0755 root root -"
|
||||||
|
"d ${httpRoot}/nixos-minimal 0755 root root -"
|
||||||
"d ${httpRoot}/systemrescue 0755 root root -"
|
"d ${httpRoot}/systemrescue 0755 root root -"
|
||||||
"d ${httpRoot}/ubuntu 0755 root root -"
|
"d ${httpRoot}/ubuntu 0755 root root -"
|
||||||
"d ${httpRoot}/rescue 0755 root root -"
|
"d ${httpRoot}/rescue 0755 root root -"
|
||||||
|
|||||||
@@ -1,23 +1,32 @@
|
|||||||
{ netbootSystem, ... }:
|
{ netbootSystem, netbootMinimalSystem, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
# config.system.build.kernel and .netbootRamdisk are directories, not the
|
# config.system.build.kernel and .netbootRamdisk are directories, not the
|
||||||
# files themselves — nixpkgs' own system.build.kexecTree does the same
|
# files themselves — nixpkgs' own system.build.kexecTree does the same
|
||||||
# ${...}/<file> dereference for the same reason.
|
# ${...}/<file> dereference for the same reason.
|
||||||
inherit (netbootSystem.config.system.boot.loader) kernelFile;
|
mkStageRules = { dirName, system }:
|
||||||
|
let
|
||||||
|
inherit (system.config.system.boot.loader) kernelFile;
|
||||||
|
dir = "/srv/pxe/http/${dirName}";
|
||||||
|
in
|
||||||
|
[
|
||||||
|
# Declared here too (not just in build-types/pxe-boot.nix) so this
|
||||||
|
# module's C+ rules don't depend on cross-module list-merge ordering —
|
||||||
|
# tmpfiles' C type needs the target directory to already exist.
|
||||||
|
"d ${dir} 0755 root root -"
|
||||||
|
"C+ ${dir}/${kernelFile} 0644 root root - ${system.config.system.build.kernel}/${kernelFile}"
|
||||||
|
"C+ ${dir}/initrd 0644 root root - ${system.config.system.build.netbootRamdisk}/initrd"
|
||||||
|
"C+ ${dir}/netboot.ipxe 0644 root root - ${system.config.system.build.netbootIpxeScript}/netboot.ipxe"
|
||||||
|
];
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# Builds this flake's own installer netboot image (the same one
|
# Builds this flake's own installer netboot image (the same one
|
||||||
# `nix build .#pxe` produces) and stages it where menu.ipxe's :nixos
|
# `nix build .#pxe` produces) plus the vanilla NixOS minimal netboot image
|
||||||
# entry expects it, so the pxe-boot host is self-contained — no manual
|
# (`nix build .#pxe-minimal`), and stages both where menu.ipxe's
|
||||||
# operator step to populate /srv/pxe/http/nixos after deploy.
|
# :auto-installer / :nixos-minimal entries expect them, so the pxe-boot
|
||||||
systemd.tmpfiles.rules = [
|
# host is self-contained — no manual operator step to populate
|
||||||
# Declared here too (not just in build-types/pxe-boot.nix) so this
|
# /srv/pxe/http after deploy.
|
||||||
# module's C+ rules don't depend on cross-module list-merge ordering —
|
systemd.tmpfiles.rules =
|
||||||
# tmpfiles' C type needs the target directory to already exist.
|
mkStageRules { dirName = "auto-installer"; system = netbootSystem; }
|
||||||
"d /srv/pxe/http/nixos 0755 root root -"
|
++ mkStageRules { dirName = "nixos-minimal"; system = netbootMinimalSystem; };
|
||||||
"C+ /srv/pxe/http/nixos/${kernelFile} 0644 root root - ${netbootSystem.config.system.build.kernel}/${kernelFile}"
|
|
||||||
"C+ /srv/pxe/http/nixos/initrd 0644 root root - ${netbootSystem.config.system.build.netbootRamdisk}/initrd"
|
|
||||||
"C+ /srv/pxe/http/nixos/netboot.ipxe 0644 root root - ${netbootSystem.config.system.build.netbootIpxeScript}/netboot.ipxe"
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user