mirror of
https://github.com/NiklasGollenstede/nixos-installer.git
synced 2025-08-16 11:44:47 +02:00
fix gptfdisk, integrate some bash aliases
This commit is contained in:
@ -24,9 +24,11 @@ in {
|
||||
|
||||
options.${prefix} = { bootloader.extlinux = {
|
||||
enable = lib.mkEnableOption (lib.mdDoc ''
|
||||
a simple bootloader for legacy-BIOS environments, like (by default) Qemu.
|
||||
extlinux, a simple bootloader for legacy-BIOS environments, like (by default) Qemu.
|
||||
This uses the same implementation as `boot.loader.generic-extlinux-compatible` to generate the bootloader configuration, but then actually also installs `extlinux` itself, instead of relying on something else (like an externally installed u-boot) to read and execute the configuration.
|
||||
Any options affecting the config file generation by `boot.loader.generic-extlinux-compatible` apply, but `boot.loader.generic-extlinux-compatible.enable` should not be set to `true`.
|
||||
|
||||
Since the bootloader runs before selecting a generation or specialisation to run, all sub-options, similar to e.g. {option}`boot.loader.timeout`, apply globally to the system, from whichever configuration last applied its bootloader (e.g. by newly `nixos-rebuild switch/boot`ing it or by calling its `.../bin/switch-to-configuration switch/boot`)
|
||||
'');
|
||||
package = lib.mkOption { description = lib.mdDoc ''
|
||||
The `syslinux` package to install `extlinux` from use.
|
||||
@ -38,13 +40,15 @@ in {
|
||||
The `/dev/disk/by-{id,label,partlabel,partuuid,uuid}/*` path of the *disk partition* holding the filesystem that `extlinux` is installed to. This must be formatted with a filesystem that `extlinux` supports and mounted as (a parent of) {option}`.targetDir`. The disk on which the partition lies will have the bootloader section of its MBR replaced by `extlinux`'s.
|
||||
''; type = lib.types.strMatching ''^/.*[^/]$''; default = targetMount.device; };
|
||||
allowInstableTargetPart = lib.mkOption { internal = true; type = lib.types.bool; };
|
||||
showUI = (lib.mkEnableOption (lib.mdDoc "a simple graphical user interface to select the configuration to start during early boot.")) // { default = true; example = false; };
|
||||
showUI = (lib.mkEnableOption (lib.mdDoc ''
|
||||
a simple graphical user interface to select the configuration to start during early boot
|
||||
'')) // { default = true; example = false; };
|
||||
}; };
|
||||
|
||||
config = let
|
||||
|
||||
confFile = "/nixos/modules/system/boot/loader/generic-extlinux-compatible";
|
||||
writeConfig = (import "${inputs.nixpkgs}/${confFile}" { inherit config pkgs lib; }).config.content.system.build.installBootLoader;
|
||||
generic-extlinux-compatible = "${inputs.nixpkgs}/nixos/modules/system/boot/loader/generic-extlinux-compatible";
|
||||
extlinux-conf-builder = (import generic-extlinux-compatible { inherit config pkgs lib; }).config.content.system.build.installBootLoader;
|
||||
|
||||
esc = lib.escapeShellArg;
|
||||
|
||||
@ -52,10 +56,14 @@ in {
|
||||
|
||||
assertions = [ {
|
||||
assertion = cfg.allowInstableTargetPart || (builtins.match ''^/dev/disk/by-(id|label|partlabel|partuuid|uuid)/.*[^/]$'' cfg.targetPart) != null;
|
||||
message = ''`config.${prefix}.bootloader.extlinux.targetPart` is not set to a stable path in `/dev/disk/by-{id,label,partlabel,partuuid,uuid}/`. Not using a unique identifier (or even using a path that can unexpectedly change) is very risky.'';
|
||||
message = ''
|
||||
`config.${prefix}.bootloader.extlinux.targetPart` is not set to a stable path in `/dev/disk/by-{id,label,partlabel,partuuid,uuid}/`. Not using a unique identifier (or even using a path that can unexpectedly change) is very risky.
|
||||
'';
|
||||
} {
|
||||
assertion = fsSupported targetMount.fsType;
|
||||
message = ''`config.${prefix}.bootloader.extlinux.targetPart`'s closest mount (`${targetMount.mountPoint}`) is of type `${targetMount.fsType}`, which is not one of extlinux's supported types (${lib.concatStringsSep ", " supportedFSes}).'';
|
||||
message = ''
|
||||
`config.${prefix}.bootloader.extlinux.targetPart`'s closest mount (`${targetMount.mountPoint}`) is of type `${targetMount.fsType}`, which is not one of extlinux's supported types (${lib.concatStringsSep ", " supportedFSes}).
|
||||
'';
|
||||
} ];
|
||||
|
||||
${prefix} = {
|
||||
@ -65,7 +73,8 @@ in {
|
||||
|
||||
system.boot.loader.id = "extlinux";
|
||||
system.build.installBootLoader = "${pkgs.writeShellScript "install-extlinux.sh" ''
|
||||
${writeConfig} "$1" -d ${esc cfg.targetDir}
|
||||
if [[ ! ''${1:-} || $1 != /nix/store/* ]] ; then echo "Usage: $0 TOPLEVEL_PATH" ; exit 1 ; fi
|
||||
${extlinux-conf-builder} "$1" -d ${esc cfg.targetDir}
|
||||
|
||||
partition=${esc cfg.targetPart}
|
||||
diskDev=$( realpath "$partition" ) || exit ; if [[ $diskDev == /dev/sd* ]] ; then
|
||||
@ -75,7 +84,9 @@ in {
|
||||
fi
|
||||
|
||||
if [[ $( cat ${esc cfg.targetDir}/extlinux/installedVersion 2>/dev/null || true ) != ${esc cfg.package} ]] ; then
|
||||
${esc cfg.package}/bin/extlinux --install ${esc cfg.targetDir}/extlinux || exit
|
||||
if ! output=$( ${esc cfg.package}/bin/extlinux --install --heads=64 --sectors=32 ${esc cfg.targetDir}/extlinux 2>&1 ) ; then
|
||||
printf '%s\n' "$output" ; exit 1
|
||||
fi
|
||||
printf '%s\n' ${esc cfg.package} >${esc cfg.targetDir}/extlinux/installedVersion
|
||||
fi
|
||||
if ! ${pkgs.diffutils}/bin/cmp --quiet --bytes=440 $diskDev ${esc cfg.package}/share/syslinux/mbr.bin ; then
|
||||
@ -88,9 +99,11 @@ in {
|
||||
cp ${esc cfg.package}/share/syslinux/$lib.c32 ${esc cfg.targetDir}/extlinux/$lib.c32
|
||||
fi
|
||||
done
|
||||
if ! ${pkgs.gnugrep}/bin/grep -qP '^UI $' ${esc cfg.targetDir}/extlinux/extlinux.conf ; then
|
||||
if ! ${pkgs.gnugrep}/bin/grep -qP '^UI ' ${esc cfg.targetDir}/extlinux/extlinux.conf ; then # `extlinux-conf-builder` above would have recreated this, so the check should always be true
|
||||
${pkgs.perl}/bin/perl -i -pe 's/TIMEOUT/UI menu.c32\nTIMEOUT/' ${esc cfg.targetDir}/extlinux/extlinux.conf
|
||||
fi
|
||||
else
|
||||
: # delete library files?
|
||||
fi
|
||||
''}";
|
||||
|
||||
|
Reference in New Issue
Block a user