diff options
| author | Ben Sima <ben@bsima.me> | 2025-11-15 09:36:40 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bsima.me> | 2025-11-15 09:36:40 -0500 |
| commit | 905c6aa06c00150f0c051ead776a64aee0b2212c (patch) | |
| tree | 7d7159ebf4befb1d9c13e1bd4e4dc177c8e0599b /Biz.nix | |
| parent | 027ff609365dd0775823b7cb45b8d2d06ee3a35d (diff) | |
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 <amp@ampcode.com>
Diffstat (limited to 'Biz.nix')
| -rwxr-xr-x | Biz.nix | 68 |
1 files changed, 36 insertions, 32 deletions
@@ -1,34 +1,38 @@ #!/usr/bin/env run.sh # nunya -{bild, ...}: -# This is the biz hosting service. Currently it defines a base OS similar to -# Omni/Cloud.nix et al and starts each Biz/* thing as a systemd service. A -# better solution might be to define each Biz/* thing as a container, and then -# wire them together as necessary here, but I don't know how that works so I'll -# just stick to this method for now. -bild.os { - imports = [ - ./Omni/Cloud/Hardware.nix - ./Omni/Os/Base.nix - ./Omni/Packages.nix - ./Omni/Users.nix - ./Biz/Storybook.nix - ./Biz/PodcastItLater/Web.nix - ./Biz/PodcastItLater/Worker.nix - ]; - networking.hostName = "biz"; - networking.domain = "storybook.bensima.com"; - time.timeZone = "America/New_York"; - services.storybook = { - enable = false; - package = bild.run ./Biz/Storybook.py; - }; - services.podcastitlater-web = { - enable = true; - package = bild.run ./Biz/PodcastItLater/Web.py; - }; - services.podcastitlater-worker = { - enable = true; - package = bild.run ./Biz/PodcastItLater/Worker.py; - }; -} +{bild, ...}: let + # Pre-declared targets prevent recursive builds during NixOS evaluation. + # All bild.run calls happen once at this top level. + targets = import ./Biz/Targets.nix {inherit bild;}; +in + # This is the biz hosting service. Currently it defines a base OS similar to + # Omni/Cloud.nix et al and starts each Biz/* thing as a systemd service. A + # better solution might be to define each Biz/* thing as a container, and then + # wire them together as necessary here, but I don't know how that works so I'll + # just stick to this method for now. + bild.os { + imports = [ + ./Omni/Cloud/Hardware.nix + ./Omni/Os/Base.nix + ./Omni/Packages.nix + ./Omni/Users.nix + ./Biz/Storybook.nix + ./Biz/PodcastItLater/Web.nix + ./Biz/PodcastItLater/Worker.nix + ]; + networking.hostName = "biz"; + networking.domain = "storybook.bensima.com"; + time.timeZone = "America/New_York"; + services.storybook = { + enable = false; + package = targets.storybook; + }; + services.podcastitlater-web = { + enable = true; + package = targets.podcastitlater-web; + }; + services.podcastitlater-worker = { + enable = true; + package = targets.podcastitlater-worker; + }; + } |
