Skip to content

Commit 25c5998

Browse files
fix(provider-core): Nix store provider installs no longer offer an update that can't run (pingdotgg#27706)
1 parent 962eeef commit 25c5998

5 files changed

Lines changed: 77 additions & 2 deletions

File tree

‎docs/internals/providers.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ mise tool; mise must resolve the binary and list it in an active install of that
9797
path must be a shim or under the tool's `latest` link, which the upgrade repoints: a version
9898
directory (including one `mise activate` put on `PATH`) would keep running the old binary until mise
9999
prunes it. Everything else mise touches (fixed version paths, pinned tools, wrappers, OpenCode 1.x,
100-
whose mise tool crosses into 2.x) stays manual-only, so T3 Code never edits mise config. `mise latest` supplies the version, because settings such as
100+
whose mise tool crosses into 2.x) stays manual-only, so T3 Code never edits mise config. Nix store installs stay manual-only too, since the store is read-only. `mise latest` supplies the version, because settings such as
101101
`minimum_release_age` can hold mise behind npm. A Grok cask whose Homebrew prefix
102102
cannot be verified also stays manual-only: `grok update` would install a second copy. npm updates pin `--prefix` because the
103103
`npm` on `PATH` can belong to a different Node than the one that owns the provider. Homebrew

‎docs/user/install.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ installer you used. T3 Code runs `mise upgrade`
220220
only for a tool your mise config requests as `latest` when the provider's binary
221221
path is a mise shim or under the tool's `installs/<tool>/latest` link; update a
222222
pinned version, or a path into one version's directory, through mise yourself.
223+
Update a CLI installed with Nix through Nix.
223224
Cursor and Antigravity update with T3 Code. Homebrew and Chocolatey installs
224225
compare against the version their package manager offers, which can trail the
225226
npm release; update Claude installed with Chocolatey through Chocolatey.

‎packages/provider-core/src/server/maintenanceResolver.test.ts‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,63 @@ it.layer(
10161016
}),
10171017
);
10181018

1019+
it.effect.each([
1020+
{
1021+
name: "a home-manager link in the native location",
1022+
definition: claudeUpdate,
1023+
resolved: "/home/me/.local/bin/claude",
1024+
real: "/nix/store/0c2kbzqz3m0m4hcx2g7hq1n5wfs9a6xd-claude-code-with-bun/bin/claude",
1025+
},
1026+
{
1027+
name: "another provider's profile link",
1028+
definition: otherProviderUpdate,
1029+
resolved: "/etc/profiles/per-user/me/bin/native-package-tool",
1030+
real: "/nix/store/0c2kbzqz3m0m4hcx2g7hq1n5wfs9a6xd-native-package-tool-1.0.0/bin/native-package-tool",
1031+
},
1032+
] as const)("keeps a Nix store install manual-only through $name", (fixture) =>
1033+
Effect.gen(function* () {
1034+
const capabilities = yield* resolveInstall({ ...fixture, platform: "linux" });
1035+
1036+
expect(capabilities.update).toBeNull();
1037+
}),
1038+
);
1039+
1040+
it.effect.skipIf(windowsHost)("upgrades a mise tool through a shim of a Nix-installed mise", () =>
1041+
Effect.gen(function* () {
1042+
const tempDir = yield* makeTempDir("t3-nix-mise-shim");
1043+
const mise = miseFixture(tempDir, { misePresent: false });
1044+
const nixMise = "/nix/store/0c2kbzqz3m0m4hcx2g7hq1n5wfs9a6xd-mise-2026.1.0/bin/mise";
1045+
const spawned: Array<ReadonlyArray<string>> = [];
1046+
1047+
const capabilities = yield* resolvePackageManagedProviderMaintenance(
1048+
{
1049+
provider: driver("packageTool"),
1050+
npmPackageName: "@example/package-tool",
1051+
mise: { tool: "package-tool" },
1052+
nativeUpdate: null,
1053+
},
1054+
{
1055+
binaryPath: "package-tool",
1056+
resolvedCommandPath: NodePath.join(tempDir, "mise", "shims", "package-tool"),
1057+
realCommandPath: nixMise,
1058+
env: { PATH: "" },
1059+
platform: "linux",
1060+
},
1061+
).pipe(
1062+
Effect.provideService(HostProcess.Platform, "linux"),
1063+
Effect.provideService(
1064+
ChildProcessSpawner.ChildProcessSpawner,
1065+
miseSpawner({ which: mise.binaryPath, installed: mise.installed() }, spawned),
1066+
),
1067+
);
1068+
1069+
expect(capabilities.update).toMatchObject({
1070+
executable: nixMise,
1071+
args: ["upgrade", "package-tool"],
1072+
});
1073+
}),
1074+
);
1075+
10191076
it.effect("proves Windows npm ownership from the package manifest beside the shim", () =>
10201077
Effect.gen(function* () {
10211078
const tempDir = yield* makeTempDir("t3-npm-windows-capabilities");

‎packages/provider-core/src/server/maintenanceResolver.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ function isMiseExecutablePath(commandPath: string): boolean {
269269
return /(?:^|\/)mise(?:\.exe)?$/.test(normalizeCommandPath(commandPath));
270270
}
271271

272+
/** The Nix store is read-only, so no updater can replace a CLI that lives there. */
273+
export function isNixStoreCommandPath(commandPath: string): boolean {
274+
return normalizeCommandPath(commandPath).startsWith("/nix/store/");
275+
}
276+
272277
const winGetClaudeCommandPath =
273278
/^[a-z]:\/(?:users\/[^/]+\/appdata\/local\/microsoft|program files(?: \(x86\))?)\/winget\/(?:links|packages\/anthropic\.claudecode_[^/]+)\/claude\.exe$/;
274279

@@ -672,6 +677,10 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
672677
context,
673678
);
674679
if (mise) return mise;
680+
// After mise: a shim of a Nix-installed mise resolves into the store, yet its installs are writable.
681+
if (commandPaths.some(isNixStoreCommandPath)) {
682+
return manual;
683+
}
675684

676685
const nativeUpdate = definition.nativeUpdate;
677686
const nativeEnv = nativeUpdate?.env;

‎packages/provider-grok/src/server/driver.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { mergeProviderInstanceEnvironment } from "@t3tools/provider-core/server/
3232
import { discoverGrokSkills } from "./skills.ts";
3333
import {
3434
homebrewOwnershipFromCommandPath,
35+
isNixStoreCommandPath,
3536
makeCachedProviderMaintenanceResolution,
3637
makeManualOnlyProviderMaintenanceCapabilities,
3738
makeProviderMaintenanceCapabilities,
@@ -53,7 +54,7 @@ const GROK_NPM_PACKAGE = "@xai-official/grok";
5354
// `grok update` installs under `GROK_HOME` from the resolved executable and instance environment.
5455
// npm 12 blocks the postinstall that moves the new binary in, yet exits 0, so allow it by env.
5556
// Mise and Homebrew casks upgrade through their manager; `grok update` would install a second
56-
// copy, so a cask its brew cannot vouch for stays manual.
57+
// copy, so a cask its brew cannot vouch for stays manual, as does a Nix store install.
5758
const UPDATE: ProviderMaintenanceCapabilitiesResolver = {
5859
resolve: Effect.fn("resolveGrokMaintenance")(function* (context) {
5960
if (!context) {
@@ -68,6 +69,13 @@ const UPDATE: ProviderMaintenanceCapabilitiesResolver = {
6869
context,
6970
);
7071
if (mise) return mise;
72+
if ([context.resolvedCommandPath, context.realCommandPath].some(isNixStoreCommandPath)) {
73+
return makeManualOnlyProviderMaintenanceCapabilities({
74+
provider: DRIVER_KIND,
75+
packageName: GROK_NPM_PACKAGE,
76+
installPath: context.realCommandPath,
77+
});
78+
}
7179
const homebrew = homebrewOwnershipFromCommandPath(context.realCommandPath);
7280
// Only a cask is Grok's: a formula keg such as `node` holding an npm global is not.
7381
if (homebrew?.kind === "cask") {

0 commit comments

Comments
 (0)