Files
Emily fdb820602b treewide: drop simple x86_64-darwin mentions
To reproduce:

    $ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
        -- scan --update-all --inline-rules '
          id: nix-x86_64-darwin
          language: nix
          rule:
            any:
              - pattern: "\"x86_64-darwin\""
                kind: list_expression > string_expression
              - pattern:
                  context: "{ \"x86_64-darwin\" = $EXPR; }"
                  selector: binding
              - pattern:
                  context: "{ x86_64-darwin = $EXPR; }"
                  selector: binding
          fix:
            template: ""
        ' pkgs
    $ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
        -- scan --update-all --inline-rules '
          id: json-first-x86_64-darwin
          language: json
          rule:
            kind: object > pair:nth-child(1)
            has:
              pattern: "\"x86_64-darwin\""
              field: key
          fix:
            template: ""
            expandEnd: { regex: "," }
        ' pkgs
    $ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
        -- scan --update-all --inline-rules '
          id: json-x86_64-darwin
          language: json
          rule:
            kind: object > pair
            has:
              pattern: "\"x86_64-darwin\""
              field: key
          fix:
            template: ""
            expandStart: { regex: "," }
        ' pkgs
    $ git restore pkgs/by-name/om/omnix/package.nix
    $ git diff --name-only -z \
        | nix shell nixpkgs/3b32825de172d0bc85664f495edb096b10862524#gnused \
            -c xargs -0 sed -i '/^$/N; /^\n\? \+$/d'
    $ treefmt
2026-07-15 03:58:16 +01:00

120 lines
3.7 KiB
Nix

{
lib,
stdenv,
fetchurl,
autoPatchelfHook,
makeWrapper,
writeShellScript,
curl,
common-updater-scripts,
gnused,
cctools,
darwin,
rcodesign,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "codegraph";
version = "1.4.1";
src =
finalAttrs.passthru.sources.${stdenv.hostPlatform.system}
or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
sourceRoot =
{
"aarch64-darwin" = "codegraph-darwin-arm64";
"aarch64-linux" = "codegraph-linux-arm64";
"x86_64-linux" = "codegraph-linux-x64";
}
.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
strictDeps = true;
__structuredAttrs = true;
nativeBuildInputs = [
makeWrapper
]
++ lib.optionals stdenv.hostPlatform.isLinux [
autoPatchelfHook
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
cctools
rcodesign
];
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
stdenv.cc.cc.lib
];
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out/lib/codegraph
cp -r lib $out/lib/codegraph/lib
cp node $out/lib/codegraph/node
install -Dm 755 bin/codegraph $out/lib/codegraph/bin/codegraph
mkdir -p $out/bin
makeWrapper $out/lib/codegraph/bin/codegraph $out/bin/codegraph
runHook postInstall
'';
postFixup = lib.optionalString stdenv.hostPlatform.isDarwin ''
'${lib.getExe' cctools "${cctools.targetPrefix}install_name_tool"}' $out/lib/codegraph/node \
-change /usr/lib/libicucore.A.dylib '${lib.getLib darwin.ICU}/lib/libicucore.A.dylib'
'${lib.getExe rcodesign}' sign --code-signature-flags linker-signed $out/lib/codegraph/node
'';
passthru = {
sources = {
"aarch64-darwin" = fetchurl {
url = "https://github.com/colbymchenry/codegraph/releases/download/v${finalAttrs.version}/codegraph-darwin-arm64.tar.gz";
hash = "sha256-Smea5aXLn/+QDdWbt4baalgbf2j0z3E73t0TfjR9NNw=";
};
"aarch64-linux" = fetchurl {
url = "https://github.com/colbymchenry/codegraph/releases/download/v${finalAttrs.version}/codegraph-linux-arm64.tar.gz";
hash = "sha256-DWLF6yci+NGdIPehvZdEReGNUpTLWb4Ragw9Vc6HWR8=";
};
"x86_64-linux" = fetchurl {
url = "https://github.com/colbymchenry/codegraph/releases/download/v${finalAttrs.version}/codegraph-linux-x64.tar.gz";
hash = "sha256-+1hf9QGNb6qkbSgrYfT2ibx5Z+2KG0Z6XFVt187ZtUI=";
};
};
updateScript = writeShellScript "update-codegraph" ''
set -o errexit
export PATH="${
lib.makeBinPath [
curl
common-updater-scripts
gnused
]
}"
NEW_VERSION=$(curl --silent -fsSLI -o /dev/null -w '%{url_effective}' "https://github.com/colbymchenry/codegraph/releases/latest" | sed -n 's#.*/releases/tag/v##p')
if [[ "${finalAttrs.version}" = "$NEW_VERSION" ]]; then
echo "The new version same as the old version."
exit 0
fi
for platform in ${lib.escapeShellArgs finalAttrs.meta.platforms}; do
update-source-version "codegraph" "$NEW_VERSION" --ignore-same-version --source-key="sources.$platform"
done
'';
};
meta = {
description = "Pre-indexed code knowledge graph for AI coding agents";
homepage = "https://github.com/colbymchenry/codegraph";
changelog = "https://github.com/colbymchenry/codegraph/releases/tag/v${finalAttrs.version}";
license = lib.licenses.mit;
mainProgram = "codegraph";
maintainers = [ lib.maintainers.gdifolco ];
platforms = builtins.attrNames finalAttrs.passthru.sources;
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
};
})