From b3dd5f285365f59153a8f4549efa0607ccddf19d Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sat, 15 Nov 2025 10:06:18 -0500 Subject: Fix NixOS integration: separate package building from OS builds Problem: Calling bild.run inside NixOS configs triggered IFD during OS evaluation. ANSI escape codes from bild broke JSON parsing in Nix sandbox, causing build failures. Root cause: bild.run uses IFD (Import From Derivation) which runs bild --plan during Nix evaluation. When this happened inside NixOS service definitions, it ran recursively and bild output ANSI codes that corrupted the JSON analysis output. Solution: Two-phase architecture + NO_COLOR support 1. Biz/Packages.nix: Pre-builds all packages outside NixOS context 2. Biz.nix: Accepts packages as function argument (default: Packages.nix) 3. Omni/Bild.nix: Sets NO_COLOR=1 in analysis derivation 4. Omni/Log/Terminal.hs: Respects NO_COLOR env var 5. Omni/Log/Terminal.hs: Skip getTerminalSize when NO_COLOR set to avoid escape code output 6. Omni/Log/Concurrent.hs: Skip line initialization without ANSI support Now NixOS builds succeed: - Package IFD happens once at top level - No recursive builds during service evaluation - Clean JSON output from bild --plan in Nix sandbox - NixOS configs reference pre-analyzed packages Changes: - Add Biz/Packages.nix - standalone package builder - Update Biz.nix to accept packages argument - Update Biz/Dragons/Analysis.nix to use Packages.nix - Remove Biz/Targets.nix (replaced by Packages.nix) - Add NO_COLOR support throughout logging stack - Fix ANSI.getTerminalSize outputting escape codes when NO_COLOR set Amp-Thread-ID: https://ampcode.com/threads/T-bc0f6fc7-46bf-4aa2-892e-dd62e7251d4b Co-authored-by: Amp --- Biz/Dragons/Analysis.nix | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'Biz/Dragons/Analysis.nix') diff --git a/Biz/Dragons/Analysis.nix b/Biz/Dragons/Analysis.nix index de641e8..b0e0cc9 100755 --- a/Biz/Dragons/Analysis.nix +++ b/Biz/Dragons/Analysis.nix @@ -1,18 +1,19 @@ #!/usr/bin/env run.sh -{bild}: let - targets = import ../Targets.nix {inherit bild;}; -in - # Run this like so: - # - # bild Biz/Dragons/Analysis.nix - # docker load < _/nix/Biz/Dragons/Analysis.nix - # docker run --volume $PWD:/src dragons-analyze dragons-analyze /src/.git - bild.image { - name = "dragons-analyze"; - tag = "latest"; - fromImage = null; - fromImageName = null; - fromImageTag = "latest"; - contents = [bild.pkgs.git targets.dragons-analysis]; - config.Cmd = ["/bin/dragons-analyze"]; - } +{ + bild, + packages ? import ../Packages.nix {inherit bild;}, +}: +# Run this like so: +# +# bild Biz/Dragons/Analysis.nix +# docker load < _/nix/Biz/Dragons/Analysis.nix +# docker run --volume $PWD:/src dragons-analyze dragons-analyze /src/.git +bild.image { + name = "dragons-analyze"; + tag = "latest"; + fromImage = null; + fromImageName = null; + fromImageTag = "latest"; + contents = [bild.pkgs.git packages.dragons-analysis]; + config.Cmd = ["/bin/dragons-analyze"]; +} -- cgit v1.2.3