mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-09-28 10:50:15 +00:00
opencode{,-desktop}: 1.18.13 -> 1.18.16 (#550458)
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
{
|
||||
lib,
|
||||
stdenvNoCC,
|
||||
stdenv,
|
||||
bun,
|
||||
darwin,
|
||||
fetchFromGitHub,
|
||||
makeBinaryWrapper,
|
||||
models-dev,
|
||||
@@ -13,10 +14,74 @@
|
||||
versionCheckHook,
|
||||
writableTmpDirAsHomeHook,
|
||||
}:
|
||||
let
|
||||
node_modules =
|
||||
finalAttrs:
|
||||
stdenv.mkDerivation {
|
||||
pname = "${finalAttrs.pname}-node_modules";
|
||||
inherit (finalAttrs) version src;
|
||||
|
||||
stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [
|
||||
"GIT_PROXY_COMMAND"
|
||||
"SOCKS_SERVER"
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
bun
|
||||
writableTmpDirAsHomeHook
|
||||
];
|
||||
|
||||
dontConfigure = true;
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
export BUN_INSTALL_CACHE_DIR=$(mktemp -d)
|
||||
bun install \
|
||||
--cpu="*" \
|
||||
--frozen-lockfile \
|
||||
--filter ./ \
|
||||
--filter ./packages/app \
|
||||
--filter ./packages/desktop \
|
||||
--filter ./packages/opencode \
|
||||
--filter ./packages/shared \
|
||||
--ignore-scripts \
|
||||
--no-progress \
|
||||
--os="*"
|
||||
|
||||
bun --bun ./nix/scripts/canonicalize-node-modules.ts
|
||||
bun --bun ./nix/scripts/normalize-bun-binaries.ts
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out
|
||||
find . -type d -name node_modules -exec cp -R --parents {} $out \;
|
||||
|
||||
# opencode targets only Linux and Darwin (see meta.platforms), so the
|
||||
# Windows executables that "bun install --os=*" fetches are never
|
||||
# executed. Dropping them keeps the output reproducible on hosts whose
|
||||
# security endpoint agents scan the store, and removes the vulnerable
|
||||
# bundled 7za.exe that will be quarantined.
|
||||
find $out -type f -name '*.exe' -delete
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
# NOTE: Required else we get errors that our fixed-output derivation references store paths
|
||||
dontFixup = true;
|
||||
|
||||
outputHash = "sha256-GBLs3nXtfSeXb4jXxSNM8ElMa/e/EB4sZn3c2inHnco=";
|
||||
outputHashAlgo = "sha256";
|
||||
outputHashMode = "recursive";
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "opencode";
|
||||
version = "1.18.13";
|
||||
version = "1.18.16";
|
||||
|
||||
__structuredAttrs = true;
|
||||
strictDeps = true;
|
||||
@@ -25,90 +90,40 @@ stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
owner = "anomalyco";
|
||||
repo = "opencode";
|
||||
tag = "v${finalAttrs.version}";
|
||||
hash = "sha256-xjzxTsMN4dMax3rL+2+4og0E7LovwYFvpU7Ea2sh6tM=";
|
||||
hash = "sha256-AP2W443Zk/X8j6BWfMgAEbR4BQiJgnPpr1OG6JWIprE=";
|
||||
};
|
||||
|
||||
node_modules = stdenvNoCC.mkDerivation {
|
||||
pname = "${finalAttrs.pname}-node_modules";
|
||||
inherit (finalAttrs) version src;
|
||||
|
||||
impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [
|
||||
"GIT_PROXY_COMMAND"
|
||||
"SOCKS_SERVER"
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
bun
|
||||
writableTmpDirAsHomeHook
|
||||
];
|
||||
|
||||
dontConfigure = true;
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
export BUN_INSTALL_CACHE_DIR=$(mktemp -d)
|
||||
bun install \
|
||||
--cpu="*" \
|
||||
--frozen-lockfile \
|
||||
--filter ./ \
|
||||
--filter ./packages/app \
|
||||
--filter ./packages/desktop \
|
||||
--filter ./packages/opencode \
|
||||
--filter ./packages/shared \
|
||||
--ignore-scripts \
|
||||
--no-progress \
|
||||
--os="*"
|
||||
|
||||
bun --bun ./nix/scripts/canonicalize-node-modules.ts
|
||||
bun --bun ./nix/scripts/normalize-bun-binaries.ts
|
||||
|
||||
runHook postBuild
|
||||
postPatch =
|
||||
# Relax Bun version check to be a warning instead of an error
|
||||
''
|
||||
substituteInPlace packages/script/src/index.ts \
|
||||
--replace-fail \
|
||||
'throw new Error(`This script requires bun@''${expectedBunVersionRange}' \
|
||||
'console.warn(`Warning: This script requires bun@''${expectedBunVersionRange}'
|
||||
''
|
||||
# Skip smoke test
|
||||
+ ''
|
||||
substituteInPlace packages/opencode/script/build.ts \
|
||||
--replace-fail \
|
||||
'if (item.os === process.platform && item.arch === process.arch && !item.abi)' \
|
||||
'if (false)'
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out
|
||||
find . -type d -name node_modules -exec cp -R --parents {} $out \;
|
||||
|
||||
# opencode targets only Linux and Darwin (see meta.platforms), so the
|
||||
# Windows executables that "bun install --os=*" fetches are never
|
||||
# executed. Dropping them keeps the output reproducible on hosts whose
|
||||
# security endpoint agents scan the store, and removes the vulnerable
|
||||
# bundled 7za.exe that will be quarantined.
|
||||
find $out -type f -name '*.exe' -delete
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
# NOTE: Required else we get errors that our fixed-output derivation references store paths
|
||||
dontFixup = true;
|
||||
|
||||
outputHash = "sha256-gb1vgLGiK56A9Xtg71d2J9ct8TJAjDg1A7cOUx0v3cA=";
|
||||
outputHashAlgo = "sha256";
|
||||
outputHashMode = "recursive";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
bun
|
||||
nodejs
|
||||
installShellFiles
|
||||
makeBinaryWrapper
|
||||
writableTmpDirAsHomeHook
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
darwin.sigtool
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
# NOTE: Relax Bun version check to be a warning instead of an error
|
||||
substituteInPlace packages/script/src/index.ts \
|
||||
--replace-fail 'throw new Error(`This script requires bun@''${expectedBunVersionRange}' \
|
||||
'console.warn(`Warning: This script requires bun@''${expectedBunVersionRange}'
|
||||
'';
|
||||
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
|
||||
cp -R ${finalAttrs.node_modules}/. .
|
||||
cp -R ${finalAttrs.passthru.node_modules}/. .
|
||||
patchShebangs node_modules
|
||||
patchShebangs packages/*/node_modules
|
||||
|
||||
@@ -143,7 +158,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
[
|
||||
ripgrep
|
||||
]
|
||||
++ lib.optionals stdenvNoCC.hostPlatform.isDarwin [
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
sysctl
|
||||
]
|
||||
)
|
||||
@@ -158,11 +173,17 @@ stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
postInstall = lib.optionalString (stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform) ''
|
||||
installShellCompletion --cmd opencode \
|
||||
--bash <($out/bin/opencode completion) \
|
||||
--zsh <(SHELL=/bin/zsh $out/bin/opencode completion)
|
||||
'';
|
||||
postInstall =
|
||||
lib.optionalString stdenv.hostPlatform.isDarwin ''
|
||||
codesign --force --sign - $out/bin/.opencode-wrapped
|
||||
''
|
||||
+ lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
|
||||
installShellCompletion --cmd opencode \
|
||||
--bash <($out/bin/opencode completion) \
|
||||
--zsh <(SHELL=/bin/zsh $out/bin/opencode completion)
|
||||
'';
|
||||
|
||||
dontStrip = true;
|
||||
|
||||
nativeInstallCheckInputs = [
|
||||
versionCheckHook
|
||||
@@ -181,6 +202,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
theme = "${finalAttrs.finalPackage}/share/theme.json";
|
||||
tui = "${finalAttrs.finalPackage}/share/tui.json";
|
||||
};
|
||||
node_modules = node_modules finalAttrs;
|
||||
updateScript = nix-update-script {
|
||||
extraArgs = [
|
||||
"--subpackage"
|
||||
|
||||
Reference in New Issue
Block a user