nix-config/modules/rpi-netboot.nix

63 lines
1.4 KiB
Nix

{ hostRegistry, pkgs, lib, ... }:
{
boot = {
loader.raspberryPi = {
enable = true;
version = 4;
};
kernelPackages = pkgs.linuxPackages_rpi4;
kernelParams = [
"verbose" "shell_on_fail"
"elevator=deadline"
];
initrd = {
network = {
enable = true;
flushBeforeStage2 = false;
};
supportedFilesystems = lib.mkForce [
"nfs"
];
# TODO: still needed?
extraUtilsCommands = ''
cp -v ${pkgs.klibc}/lib/klibc/bin.static/nfsmount $out/bin
cp -v ${pkgs.glibc}/lib/libresolv.so.* $out/lib
'';
};
tmpOnTmpfs = true;
};
fileSystems."/" = {
fsType = "tmpfs";
options = [ "mode=0755" ];
};
fileSystems."/etc" = {
fsType = "tmpfs";
options = [ "mode=0755" ];
};
fileSystems."/var" = {
fsType = "tmpfs";
options = [ "mode=0755" ];
};
fileSystems."/nix/store" = {
device = "${hostRegistry.hosts.nix-build.ip4}:/nix/store";
fsType = "nfs";
options = [ "nfsvers=3" "proto=tcp" "nolock" "hard" "async" "ro" ];
neededForBoot = true;
};
environment.systemPackages = with pkgs; [
libraspberrypi
raspberrypi-eeprom
];
systemd = {
# r/o /nix/store
services.nix-daemon.enable = false;
sockets.nix-daemon.enable = false;
};
services.journald.extraConfig = ''
Storage=volatile
'';
}