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
89 lines
2.3 KiB
Nix
89 lines
2.3 KiB
Nix
{
|
|
stdenv,
|
|
lib,
|
|
fetchurl,
|
|
gzip,
|
|
autoPatchelfHook,
|
|
versionCheckHook,
|
|
}:
|
|
let
|
|
|
|
inherit (stdenv.hostPlatform) system;
|
|
throwSystem = throw "Unsupported system: ${system}";
|
|
|
|
plat =
|
|
{
|
|
x86_64-linux = "linux_x64";
|
|
aarch64-linux = "linux_arm";
|
|
aarch64-darwin = "macos_arm";
|
|
|
|
}
|
|
.${system} or throwSystem;
|
|
|
|
hash =
|
|
{
|
|
x86_64-linux = "sha256-hx5q0JRwvmE63uOpht7+6d7/jCLeknrj2RwiiMkBllc=";
|
|
aarch64-linux = "sha256-r0gGxwhVkQ5MLTmcrBCJpKfsizAJLJYPw1VdfiHJ3i8=";
|
|
aarch64-darwin = "sha256-c0BDLK1ilDOdNYbOqzFNoJFeBUlWI7/+z7HaosM/D4o=";
|
|
}
|
|
.${system} or throwSystem;
|
|
|
|
bin = "$out/bin/codeium_language_server";
|
|
|
|
in
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
pname = "codeium";
|
|
version = "2.12.5";
|
|
src = fetchurl {
|
|
name = "${finalAttrs.pname}-${finalAttrs.version}.gz";
|
|
url = "https://github.com/Exafunction/codeium/releases/download/language-server-v${finalAttrs.version}/language_server_${plat}.gz";
|
|
inherit hash;
|
|
};
|
|
|
|
nativeBuildInputs = [ gzip ] ++ lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ];
|
|
|
|
dontUnpack = true;
|
|
dontConfigure = true;
|
|
dontBuild = true;
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
mkdir -p $out/bin
|
|
gzip -dc $src > ${bin}
|
|
chmod +x ${bin}
|
|
runHook postInstall
|
|
'';
|
|
|
|
nativeInstallCheckInputs = [
|
|
versionCheckHook
|
|
];
|
|
versionCheckProgram = "${placeholder "out"}/bin/codeium_language_server";
|
|
doInstallCheck = true;
|
|
|
|
passthru.updateScript = ./update.sh;
|
|
|
|
meta = rec {
|
|
description = "Codeium language server";
|
|
longDescription = ''
|
|
Codeium proprietary language server, patched for Nix(OS) compatibility.
|
|
bin/language_server_x must be symlinked into the plugin directory, replacing the existing binary.
|
|
For example:
|
|
```shell
|
|
ln -s "$(which codeium_language_server)" /home/a/.local/share/JetBrains/Rider2023.1/codeium/662505c9b23342478d971f66a530cd102ae35df7/language_server_linux_x64
|
|
```
|
|
'';
|
|
homepage = "https://codeium.com/";
|
|
downloadPage = homepage;
|
|
changelog = homepage;
|
|
license = lib.licenses.unfree;
|
|
maintainers = with lib.maintainers; [ anpin ];
|
|
mainProgram = "codeium_language_server";
|
|
platforms = [
|
|
"aarch64-darwin"
|
|
"aarch64-linux"
|
|
"x86_64-linux"
|
|
];
|
|
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
|
|
};
|
|
})
|