From c1101d3af5f5d4566dfdd57200af36d9d798f08d Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Mon, 8 Jan 2024 18:58:07 +0000 Subject: [PATCH] make extlinux work with liminix-rebuild add /boot to the systemConfiguration closure --- examples/rotuer.nix | 3 ++- modules/outputs/extlinux.nix | 8 ++++++-- pkgs/systemconfig/default.nix | 15 +++++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/examples/rotuer.nix b/examples/rotuer.nix index 51ce22b..d2d9f64 100644 --- a/examples/rotuer.nix +++ b/examples/rotuer.nix @@ -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; diff --git a/modules/outputs/extlinux.nix b/modules/outputs/extlinux.nix index 9f46c0a..17fde2a 100644 --- a/modules/outputs/extlinux.nix +++ b/modules/outputs/extlinux.nix @@ -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; + }; }; } diff --git a/pkgs/systemconfig/default.nix b/pkgs/systemconfig/default.nix index dae4221..129993f 100644 --- a/pkgs/systemconfig/default.nix +++ b/pkgs/systemconfig/default.nix @@ -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 '';