···1313- [x] Simple, declarative JSON configuration
1414- [x] Build a custom NixOS installer from a flake
1515- [x] Built-in PXE server based on [Pixiecore](https://github.com/danderson/netboot/tree/main/pixiecore) to serve netboot components from the custom installer
1616+- [x] Install NixOS from a flake using [nixos-anywhere](https://nix-community.github.io/nixos-anywhere)
1617- [ ] Custom agent and API to manage the installation process
1717-- [ ] Install NixOS from a flake using [nixos-anywhere](https://nix-community.github.io/nixos-anywhere)
1818- [ ] Remote power-on with [Wake-on-LAN](https://en.wikipedia.org/wiki/Wake-on-LAN)
1919- [ ] Host status check with IP discovery
2020- [x] Stateless and ephemeral [^1]
2121-- [ ] Fast, under 2 minutes to install NixOS from empty hard drives [^2]
2121+- [x] Fast, under 2 minutes to install NixOS from empty hard drives [^2]
22222323[^1]: No pre-configured PXE server is required to install other machines - you
2424 only need to run Nixie on your laptop or workstation. This solves the
···2233import (
44 "log"
55+66+ "code.khuedoan.com/nixie/internal/serve"
57)
6879func main() {
88- params, err := getNixieParams()
1010+ params, err := getAgentConfig()
911 if err != nil {
1012 log.Fatalf("failed to get Nixie params: %v", err)
1113 }
1214 log.Printf("nixie-agent params: %+v", params)
13151414- if err = ping(params.API); err != nil {
1616+ if err = ping(params.APIAddress); err != nil {
1517 log.Fatalf("failed to ping Nixie API server: %v", err)
1818+ }
1919+ log.Printf("successfully sent ping to API server")
2020+2121+ installRequest := serve.InstallRequest{
2222+ MACAddress: params.MACAddress,
2323+ }
2424+ if err = install(params.APIAddress, installRequest); err != nil {
2525+ log.Fatalf("failed to request for installation: %v", err)
1626 }
1727}
-5
cmd/nixie/main.go
···7777 }
7878 }()
79798080- // TODO IMPORTANT obviously, should be API call
8181- // TODO IMPORTANT support SSH key
8282- log.Info("installing NixOS", "host", "192.168.1.8", "flake", "./examples#machine1")
8383- nixos.Install(ctx, "./examples#machine1", "root", "192.168.1.8", "nixos-installer", flags.Debug)
8484-8580 sigCh := make(chan os.Signal, 1)
8681 signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
8782
+1
internal/nixos/installer.go
···3838}
39394040func BuildInstaller(ctx context.Context, flakeRef string, debug bool) (InstallerComponents, error) {
4141+ // TODO there might be some race condition here if we update the flake/installer content while an existing build is running, causing mismatch in init path and the actual one in the installer
4142 kernelOut, err := nixBuild(
4243 ctx,
4344 flakeRef+".config.system.build.kernel",