1# To build, use:
2# nix-build nixos -I nixos-config=nixos/modules/installer/sd-card/sd-image-powerpc64le.nix -A config.system.build.sdImage
3{
4 config,
5 lib,
6 pkgs,
7 ...
8}:
9
10{
11 imports = [
12 ../../profiles/base.nix
13 ../../profiles/installation-device.nix
14 ./sd-image.nix
15 ];
16
17 boot.loader = {
18 # powerpc64le-linux typically uses petitboot
19 grub.enable = false;
20 generic-extlinux-compatible = {
21 # petitboot is not does not support all of the extlinux extensions to
22 # syslinux, but its parser is very forgiving; it essentially ignores
23 # whatever it doesn't understand. See below for a filename adjustment.
24 enable = true;
25 };
26 };
27
28 boot.consoleLogLevel = lib.mkDefault 7;
29 boot.kernelParams = [ "console=hvc0" ];
30
31 sdImage = {
32 populateFirmwareCommands = "";
33 populateRootCommands = ''
34 mkdir -p ./files/boot
35 ${config.boot.loader.generic-extlinux-compatible.populateCmd} \
36 -c ${config.system.build.toplevel} \
37 -d ./files/boot
38 ''
39 # https://github.com/open-power/petitboot/blob/master/discover/syslinux-parser.c
40 # petitboot will look in these paths (plus all-caps versions of them):
41 # /boot/syslinux/syslinux.cfg
42 # /syslinux/syslinux.cfg
43 # /syslinux.cfg
44 + ''
45 mv ./files/boot/extlinux ./files/boot/syslinux
46 mv ./files/boot/syslinux/extlinux.conf ./files/boot/syslinux/syslinux.cfg
47 ''
48 # petitboot does not support relative paths for LINUX or INITRD; it prepends
49 # a `/` when parsing these fields
50 + ''
51 sed -i 's_^\(\W\W*\(INITRD\|initrd\|LINUX\|linux\)\W\)\.\./_\1/boot/_' ./files/boot/syslinux/syslinux.cfg
52 '';
53 };
54}