From 4f279de5fb3514d0137245d5671b037999c533e8 Mon Sep 17 00:00:00 2001 From: sstent Date: Wed, 2 Jul 2025 15:16:24 +0000 Subject: [PATCH] sync --- flake.lock | 6 +- modules/kboot-conf/default.nix | 130 +++++++++++++++++++++++++++++++-- modules/nomad.nix | 4 +- modules/odroid-m1.nix | 1 + 4 files changed, 129 insertions(+), 12 deletions(-) diff --git a/flake.lock b/flake.lock index 2a44151..f0ff6ce 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1751285371, - "narHash": "sha256-/hDU+2AUeFFu5qGHO/UyFMc4UG/x5Cw5uXO36KGTk6c=", + "lastModified": 1751382304, + "narHash": "sha256-p+UruOjULI5lV16FkBqkzqgFasLqfx0bihLBeFHiZAs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b9c03fbbaf84d85bb28eee530c7e9edc4021ca1b", + "rev": "d31a91c9b3bee464d054633d5f8b84e17a637862", "type": "github" }, "original": { diff --git a/modules/kboot-conf/default.nix b/modules/kboot-conf/default.nix index 1057ae0..3e5d8b8 100644 --- a/modules/kboot-conf/default.nix +++ b/modules/kboot-conf/default.nix @@ -7,7 +7,6 @@ with lib; let cfg = config.boot.loader.kboot-conf; - # The builder used to write during system activation # The builder used to write during system activation builder = pkgs.replaceVars ./generate-kboot-conf.sh { path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep]; @@ -19,6 +18,106 @@ with lib; let path = with pkgs.buildPackages; [coreutils gnused gnugrep]; inherit (pkgs.buildPackages) bash; }; + + # Debug wrapper function that takes args as parameter + mkDebugBuilder = args: pkgs.writeScript "kboot-debug-wrapper" '' + #!${pkgs.bash}/bin/bash + + # Set up PATH with required utilities + export PATH=${lib.makeBinPath (with pkgs; [ coreutils util-linux procps gnugrep gnused])}:$PATH + + # Create unique log file + log_file="/tmp/kboot-debug-$(date +%Y%m%d-%H%M%S)-$.log" + + # Function to log with timestamp + log() { + echo "$(date '+%Y-%m-%d %H:%M:%S'): $*" | tee -a "$log_file" + } + + # Start logging + { + log "=== KBOOT DEBUG START ===" + log "Script called with args: $*" + log "Current working directory: $(pwd)" + log "Current user: $(id)" + log "Environment variables:" + env | sort | sed 's/^/ /' + + log "System information:" + log " Hostname: $(hostname)" + log " Uptime: $(uptime)" + + log "Mount information:" + mount | grep -E "(boot|root|nix)" | sed 's/^/ /' + + log "Checking system configuration path: $1" + if [[ -n "$1" ]]; then + if [[ -e "$1" ]]; then + log " System config exists: $1" + log " Real path: $(readlink -f "$1")" + log " Contents:" + ls -la "$1" 2>&1 | sed 's/^/ /' + + # Check for required files + for file in kernel initrd dtbs nixos-version kernel-params; do + if [[ -e "$1/$file" ]]; then + log " ✓ Found $file" + if [[ "$file" == "dtbs" ]]; then + log " DTB contents:" + ls -la "$1/$file" 2>&1 | head -10 | sed 's/^/ /' + fi + else + log " ✗ Missing $file" + fi + done + else + log " ERROR: System config path does not exist: $1" + fi + else + log " ERROR: No system config path provided" + fi + + log "Boot partition status:" + if mountpoint -q /boot 2>/dev/null; then + log " ✓ /boot is mounted" + log " /boot contents:" + ls -la /boot 2>&1 | head -10 | sed 's/^/ /' + + # Test write permissions + if touch /boot/.kboot-write-test 2>/dev/null; then + log " ✓ /boot is writable" + rm -f /boot/.kboot-write-test + else + log " ✗ /boot is not writable" + fi + else + log " ✗ /boot is not mounted" + fi + + log "Process information:" + ps aux | grep -E "(nixos-rebuild|systemd)" | head -5 | sed 's/^/ /' + + log "Nix store status:" + log " Nix store mount: $(df -h /nix/store | tail -1)" + + log "=== EXECUTING ORIGINAL BUILDER ===" + log "Command: ${builder} ${args} $*" + + } 2>&1 | tee -a "$log_file" + + # Execute the original builder and capture its output + if /run/current-system/sw/bin/bash ${builder} ${args} "$@" 2>&1 | tee -a "$log_file"; then + log "=== KBOOT DEBUG SUCCESS ===" + echo "Debug log saved to: $log_file" >&2 + else + exit_code=$? + log "=== KBOOT DEBUG FAILED (exit code: $exit_code) ===" + echo "Debug log saved to: $log_file" >&2 + echo "KBOOT INSTALLATION FAILED - Check $log_file for details" >&2 + exit $exit_code + fi + ''; + in { options = { boot.loader.kboot-conf = { @@ -29,6 +128,16 @@ in { Whether to create petitboot-compatible /kboot.conf ''; }; + + debug = mkOption { + default = false; + type = types.bool; + description = '' + Whether to enable debugging output for kboot configuration generation. + Logs will be written to /tmp/kboot-debug-*.log + ''; + }; + configurationLimit = mkOption { default = 10; example = 5; @@ -37,6 +146,7 @@ in { Maximum number of configurations in the generated kboot.conf. ''; }; + populateCmd = mkOption { type = types.str; readOnly = true; @@ -49,14 +159,20 @@ in { }; }; }; + config = let args = "-g ${toString cfg.configurationLimit} -n ${config.hardware.deviceTree.name}"; - in + # Choose between debug and normal builder + activeBuilder = if cfg.debug then (mkDebugBuilder args) else builder; - mkIf cfg.enable { - system.build.installBootLoader = lib.mkForce "${builder} ${args} -c"; - system.boot.loader.id = "kboot-conf"; - boot.loader.kboot-conf.populateCmd = "${populateBuilder} ${args}"; - }; + in mkIf cfg.enable { + system.build.installBootLoader = lib.mkForce "${activeBuilder} ${args} -c"; + system.boot.loader.id = "kboot-conf"; + boot.loader.kboot-conf.populateCmd = "${populateBuilder} ${args}"; + + # Warn user about debug mode + warnings = lib.optional cfg.debug + "kboot-conf debug mode is enabled. Debug logs will be written to /tmp/kboot-debug-*.log"; + }; } diff --git a/modules/nomad.nix b/modules/nomad.nix index 3bf4f84..8c08417 100644 --- a/modules/nomad.nix +++ b/modules/nomad.nix @@ -66,7 +66,7 @@ server = { enabled = true; bootstrap_expect = 3; - start_join = ["192.168.1.225" "192.168.1.226" "192.168.1.227" "192.168.1.228"]; + start_join = ["192.168.4.225" "192.168.4.226" "192.168.4.227" "192.168.4.228"]; rejoin_after_leave = false; enabled_schedulers = ["service" "batch" "system"]; num_schedulers = 4; @@ -83,7 +83,7 @@ enabled = true; node_class = ""; no_host_uuid = false; - servers = ["192.168.1.221:4647" "192.168.1.225:4647" "192.168.1.226:4647" "192.168.1.227:4647" "192.168.1.222:4647" "192.168.1.223:4647" "192.168.1.224:4647"]; + servers = ["192.168.4.221:4647" "192.168.4.225:4647" "192.168.4.226:4647" "192.168.4.227:4647" "192.168.4.222:4647" "192.168.4.223:4647" "192.168.4.224:4647"]; max_kill_timeout = "30s"; network_speed = 0; cpu_total_compute = 0; diff --git a/modules/odroid-m1.nix b/modules/odroid-m1.nix index 1a2c066..79624a8 100644 --- a/modules/odroid-m1.nix +++ b/modules/odroid-m1.nix @@ -11,6 +11,7 @@ boot.loader.grub.enable = false; boot.loader.kboot-conf.enable = true; + boot.loader.kboot-conf.debug = true; # Use kernel >6.6 boot.kernelPackages = pkgs.linuxPackages_latest; # Stop ZFS breasking the build