summaryrefslogtreecommitdiff
path: root/Biz.nix
AgeCommit message (Collapse)Author
27 hoursFix segfault: add mutex for ANSI terminal operationsBen Sima
Problem: Intermittent segfaults when running `bild --time 0 **/*` with many concurrent builds. Core dumps showed crashes in libncursesw's free() function during terminal cleanup. Root cause: ANSI.getTerminalSize and other ANSI terminal library calls are not thread-safe. With mapConcurrentlyBounded running up to 8 analyses concurrently, multiple threads were calling ANSI functions simultaneously, causing memory corruption in the ncurses library. Solution: Add global MVar terminalLock to serialize all ANSI terminal operations. Wrap all ANSI function calls (cursor movement, line clearing, etc.) with withMVar terminalLock. Changes: - Add terminalLock :: MVar () in Omni/Log/Concurrent.hs - Wrap all ANSI calls in withMVar terminalLock: - initializeLines: cursor column, clear line - updateLine: cursor up/down, column set, clear line - updateLineState: cursor up/down, column set, clear line - withLineManager: cursor up Tested: 5 consecutive runs of `bild --time 0 **/*` complete without segfaults (previously failed 1-2 out of 3 runs).
30 hoursFix NixOS integration: separate package building from OS buildsBen Sima
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 <amp@ampcode.com>
31 hoursRefactor NixOS integration to use pre-declared targetsBen Sima
Problem: Calling bild.run inside NixOS configs triggers recursive builds during OS image creation, causing slow IFD evaluations that worsen as complexity grows. Solution: Create Biz/Targets.nix that pre-declares all buildable targets as an attribute set. NixOS configs now import and reference these targets directly, eliminating recursive builds during evaluation. Changes: - Add Biz/Targets.nix exposing storybook, podcastitlater-web, podcastitlater-worker, dragons-analysis - Update Biz.nix to import targets and reference them - Update Biz/Dragons/Analysis.nix to use targets pattern Benefits: - All bild.run calls happen once at top level during targets evaluation - NixOS service configs reference pre-built derivations - Scalable: adding targets doesn't slow individual builds - Explicit: clear what gets built for each OS Amp-Thread-ID: https://ampcode.com/threads/T-bc0f6fc7-46bf-4aa2-892e-dd62e7251d4b Co-authored-by: Amp <amp@ampcode.com>
4 daysDisable storybook for now - not working on itBen Sima
2025-08-28Prototype PodcastItLaterBen Sima
This implements a working prototype of PodcastItLater. It basically just works for a single user currently, but the articles are nice to listen to and this is something that we can start to build with.
2025-01-06Use x bit to identify buildable nix targetsBen Sima
This replaces the manually-curated nixTargets list in Bild.hs. Now any nix file that has the executable bit set will be built. I added run.sh shebangs to each of the buildable nix targets as well. When executing these, they will succeed at building, but they have no 'out' metadata, and so when run.sh tries to exec them, it will fail. This is fine for now. How would one go about execing a linux tree anyway? If all of the nix targets output something standard like a qemu image or a container, then I could have a standard wrapper that calls the image and starts the system. That might be the ideal way to have a runnable nix target. But this would require rethinking my infrastructure and how to deploy things, so I can't quite do that yet.
2025-01-02Switch to alejandra for nix formattingBen Sima
I mostly wanted a formatter that would format `inherit` blocks vertically, because otherwise they are super hard to read when diffing or even just editing. Both alejandra and the new nixos/nixfmt format verically like this, but alejandra has slightly better format (I guess) and for some reason nixfmt did not respect my `GLOBIGNORE` setting when doing `nixfmt **/*.nix` so it was trying to format stuff in `_/nix`, and failed. So anyway I went with alejandra. - https://github.com/kamadorueda/alejandra - https://discourse.nixos.org/t/enforcing-nix-formatting-in-nixpkgs/49506
2024-12-21Build and deploy storybookBen Sima
I put the storybook into a new Biz.nix deploy target. The idea here is that any Biz/* targets should be hosted by this one VM for simplicity. Over time I can grow this as need be, but this should work to host a few services.