make extlinux work with liminix-rebuild

add /boot to the systemConfiguration closure
This commit is contained in:
Daniel Barlow 2024-01-08 18:58:07 +00:00
parent 9a3d7a387e
commit c1101d3af5
3 changed files with 21 additions and 5 deletions

View file

@ -44,11 +44,12 @@ in rec {
../modules/ntp
../modules/ssh
../modules/outputs/btrfs.nix
../modules/outputs/extlinux.nix
];
hostname = "rotuer";
rootfsType = "btrfs";
rootOptions = "subvol=@";
boot.loader.extlinux.enable = true;
services.hostap = svc.hostapd.build {
interface = config.hardware.networkInterfaces.wlan;

View file

@ -6,6 +6,7 @@
}:
let
inherit (lib) mkIf mkEnableOption mkOption types concatStringsSep;
inherit (pkgs.pseudofile) dir symlink;
cfg = config.boot.loader.extlinux;
o = config.system.outputs;
cmdline = concatStringsSep " " config.boot.commandLine;
@ -17,7 +18,7 @@ in {
};
options.boot.loader.extlinux.enable = mkEnableOption "extlinux";
config = { # mkIf cfg.enable {
config = mkIf cfg.enable {
system.outputs.extlinux = pkgs.runCommand "extlinux" {} ''
mkdir $out
cd $out
@ -27,7 +28,7 @@ in {
mkdir extlinux
cat > extlinux/extlinux.conf << _EOF
menu title Liminix
timeout 100
timeout 40
label Liminix
kernel /boot/kernel
# initrd /boot/initramfs
@ -35,5 +36,8 @@ in {
${if wantsDtb then "fdt /boot/dtb" else ""}
_EOF
'';
filesystem = dir {
boot = symlink config.system.outputs.extlinux;
};
};
}

View file

@ -84,8 +84,19 @@ in attrset:
#!/bin/sh -e
prefix=\''${1-/}
src=\''${prefix}$out
mkdir -p \$prefix/persist
cp -v -fP \$src/bin/* \$src/etc/* \$prefix/persist
dest=\$prefix
${# if we are running on a normal mounted system then
# the actual device root is mounted on /persist
# and /nix is bind mounted from /persist/nix
# (see the code in preinit). So we need to check for this
# case otherwise we will install into a ramfs/rootfs
""
}
if test -d $dest/persist; then dest=$dest/persist; fi
cp -v -fP \$src/bin/* \$src/etc/* \$dest
${if attrset ? boot then ''
(cd \$prefix && rm ./boot && ln -sf ${lib.strings.removePrefix "/" attrset.boot.target} ./boot)
'' else ""}
EOF
chmod +x $out/bin/install
'';