# T3 Code built from upstream's latest stable release tag. # # pkgs/ holds the packages this repo builds itself; this is the only one, and # its update script lives beside it. # # Two nixpkgs instances meet here on purpose. The recipe is read from the # nixpkgs tree passed as `recipeSrc`, because stable 26.05 still ships a t3code # recipe for a 0.0.x tag (bun, electron_40) and 0.1.x needs the newer layout # (pnpm, electron_44, the codex and resource monitor split). Every package the # recipe calls for comes from `pkgs`, which callers set to the stable set. # # The recipe's `enableCodex` defaults on and wires the codex CLI into T3's # PATH, where it only exists for the Codex provider. This repo never uses that # provider on either host, so it is turned off: the wrapper carries no second # agent, and codex's version stops constraining the pin. The recipe still takes # a codex argument, so it gets null; with codex off T3's PATH, that provider's # health check fails on both hosts, which is the expected state. # # That split is what keeps the daily build cheap: cache.nixos.org carries # electron for the stable channel, while nixos-unstable-small does not build # it. Under unstable-small an electron patch bump meant compiling Chromium from # source on every daily update. # # The recipe rides the daily `nix flake update` of the unstable-small pin, while # the packages stay on stable. A recipe that grows an argument or a package # stable cannot supply breaks the home configuration's evaluation rather than # the tag's hashes, and pkgs/t3code/update.sh reports it as a build # failure with the pin in place, not as a bad tag. Revert the pin or vendor the # recipe when that happens. Do not swap it back to the nixpkgs `t3code` # attribute, which is the older 0.0.x recipe, and do not edit the hashes by # hand: only the updater can make them follow a tag. # # The source is upstream's tag, so the three fixed-output hashes in ./lock.nix # (repo tarball, pnpm store, cargo vendor) still move with the tag, and # pkgs/t3code/update.sh rewrites them during the daily update. { # The package set every dependency is taken from. Callers pass the stable # instance, the same one home-manager builds the app with. pkgs, # The nixpkgs tree carrying the t3code recipe, e.g. `pkgs-unstable-small.path`. # Only the recipe files are read from it; nothing it packages is used. recipeSrc, lockPath ? ./lock.nix, }: let inherit (pkgs) lib; lock = import lockPath; inherit (lock) tag rev; version = lib.removePrefix "v" tag; src = pkgs.fetchFromGitHub { owner = "pingdotgg"; repo = "t3code"; inherit rev; hash = lock.srcHash; }; base = pkgs.callPackage (recipeSrc + "/pkgs/by-name/t3/t3code/package.nix") { }; unwrapped = base.unwrapped.overrideAttrs (old: { inherit version src; pnpmDeps = old.pnpmDeps.override { inherit src version; hash = lock.pnpmDepsHash; }; }); # Built from the same src, so its version and vendor hash track the stable tag too. # # The hash goes on `cargoDeps.vendorStaging`, not on `cargoHash`. # buildRustPackage reads `cargoHash` once, when the recipe is called, and # builds the vendor staging fixed-output derivation from it into `cargoDeps`; # overriding the attribute afterwards leaves that derivation on the recipe's # hash, so the build fails on a hash the lock cannot change. The staging # derivation takes its src and version from the overridden attributes, so the # vendor tree still follows the tag and only the hash needed replacing. resourceMonitor = base.resourceMonitor.overrideAttrs (old: { inherit version src; cargoDeps = old.cargoDeps.overrideAttrs (vendor: { vendorStaging = vendor.vendorStaging.overrideAttrs (_: { outputHash = lock.cargoHash; }); }); }); in base.override { # The Codex provider is not used here; see the header. The recipe still takes # the argument, and nothing evaluates it while the provider is off. enableCodex = false; codex = null; t3code-unwrapped = unwrapped; t3code-resource-monitor = resourceMonitor; }