Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netboot with NixOS #136

Open
gianarb opened this issue Sep 20, 2022 · 1 comment
Open

Netboot with NixOS #136

gianarb opened this issue Sep 20, 2022 · 1 comment

Comments

@gianarb
Copy link

gianarb commented Sep 20, 2022

Hello! Awesome project. Simple and it does what it should I love it!

TLDR: I am not sure about how to glue all of this together in a good way

I am writing this question because I think you are faimiliar with NixOS.
I am following this guide to netboot a NixOS based operating system

https://nixos.wiki/wiki/Netboot

It generates a ipxe script file that contains the init cmdline

$ cat result/netboot.ipxe
#!ipxe
# Use the cmdline variable to allow the user to specify custom kernel params
# when chainloading this script from other iPXE scripts like netboot.xyz
kernel bzImage init=/nix/store/wc9fvfyhv649b4kxry5747rx5rw88v68-nixos-system-nixos-22.05.20220902.67e4507/init initrd=initrd loglevel=4 ${cmdline}
initrd initrd
boot

I am trying to figure out a way to teach pixiecore about this file or at least about the init location, ideally via services.pixiecore.cmdLine

@blazp7
Copy link

blazp7 commented Feb 28, 2024

I know this question is ancient, but for anyone wondering, this is what worked for me, taken from https://carjorvaz.com/posts/ipxe-booting-with-nixos

{inputs, ...}: let
  sys = inputs.nixpkgs.lib.nixosSystem {
    system = "x86_64-linux";
    modules = [
      ({
        config,
        pkgs,
        lib,
        modulesPath,
        ...
      }: {
        imports = [
          (modulesPath + "/installer/netboot/netboot-minimal.nix")
        ];
        config = {
          # custom installer configuration, most stuff is already configured by the imported module (it includes installation-device profile)
          users.users.root.initialPassword = lib.mkForce "pass123";
          users.users.nixos.initialPassword = lib.mkForce "pass123";
        };
      })
    ];
  };
  build = sys.config.system.build;
in {
  services.pixiecore = {
    enable = true;
    openFirewall = true;
    dhcpNoBind = true; # use existing DHCP server
    port = 64172;
    statusPort = 64172;

    mode = "boot";
    kernel = "${build.kernel}/bzImage";
    initrd = "${build.netbootRamdisk}/initrd";
    cmdLine = "init=${build.toplevel}/init loglevel=4";
    debug = true;
  };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants