From 905c6aa06c00150f0c051ead776a64aee0b2212c Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sat, 15 Nov 2025 09:36:40 -0500 Subject: Refactor NixOS integration to use pre-declared targets 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 --- Biz/Dragons/Analysis.nix | 32 +++++++++++++++++--------------- Biz/Targets.nix | 19 +++++++++++++++++++ 2 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 Biz/Targets.nix (limited to 'Biz') diff --git a/Biz/Dragons/Analysis.nix b/Biz/Dragons/Analysis.nix index 5ea8713..de641e8 100755 --- a/Biz/Dragons/Analysis.nix +++ b/Biz/Dragons/Analysis.nix @@ -1,16 +1,18 @@ #!/usr/bin/env run.sh -{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 (bild.run ./Analysis.hs)]; - config.Cmd = ["/bin/dragons-analyze"]; -} +{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"]; + } diff --git a/Biz/Targets.nix b/Biz/Targets.nix new file mode 100644 index 0000000..77e462c --- /dev/null +++ b/Biz/Targets.nix @@ -0,0 +1,19 @@ +# Pre-declared build targets for the Biz namespace. +# +# This file exposes all buildable Biz targets as an attribute set, allowing +# NixOS configs to reference them directly without triggering recursive builds. +# +# To add a new target: +# 1. Add the attribute here pointing to bild.run ./path/to/target +# 2. Reference it in Biz.nix or other configs as targets. +{bild}: { + # Web services + storybook = bild.run ./Storybook.py; + podcastitlater-web = bild.run ./PodcastItLater/Web.py; + podcastitlater-worker = bild.run ./PodcastItLater/Worker.py; + + # CLI tools and analysis + dragons-analysis = bild.run ./Dragons/Analysis.hs; + + # Add new Biz targets here as they are created +} -- cgit v1.2.3