tabnine: import nixpkgs update script
This commit is contained in:
parent
0e03adb60a
commit
39154b4333
5 changed files with 117 additions and 21 deletions
|
@ -32,7 +32,7 @@
|
|||
agilebits-op = import ./packages/agilebits-op.nix { inherit pkgs lib; };
|
||||
cliclick = import ./packages/cliclick.nix { inherit pkgs lib; };
|
||||
phantomjs = import ./packages/phantomjs.nix { inherit pkgs lib; };
|
||||
tabnine = import ./packages/tabnine.nix { inherit pkgs lib; };
|
||||
tabnine = import ./packages/tabnine { inherit pkgs lib; };
|
||||
} else { };
|
||||
in
|
||||
{
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
{ pkgs, lib, ... }:
|
||||
|
||||
pkgs.tabnine.overrideAttrs (
|
||||
oa: rec {
|
||||
# https://update.tabnine.com/bundles/version
|
||||
version = "4.53.0";
|
||||
|
||||
src = pkgs.fetchurl {
|
||||
url = "https://update.tabnine.com/bundles/${version}/aarch64-apple-darwin/TabNine.zip";
|
||||
sha256 = "01c1rxf6k5wv4758g9m8n6mngp07kr8xbskb5liz1x8cljcs6f72";
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://tabnine.com";
|
||||
description = "Smart Compose for code that uses deep learning to help you write code faster";
|
||||
license = licenses.unfree;
|
||||
platforms = [ "aarch64-darwin" ];
|
||||
};
|
||||
}
|
||||
)
|
55
packages/tabnine/default.nix
Normal file
55
packages/tabnine/default.nix
Normal file
|
@ -0,0 +1,55 @@
|
|||
{ pkgs, lib, ... }:
|
||||
|
||||
# Based on: https://github.com/NixOS/nixpkgs/blob/91a00709aebb3602f172a0bf47ba1ef013e34835/pkgs/development/tools/tabnine/default.nix
|
||||
|
||||
let
|
||||
stdenv = pkgs.stdenv;
|
||||
|
||||
sources = lib.importJSON ./sources.json;
|
||||
|
||||
platform =
|
||||
if (builtins.hasAttr stdenv.hostPlatform.system sources.platforms) then
|
||||
builtins.getAttr (stdenv.hostPlatform.system) sources.platforms
|
||||
else
|
||||
throw "Not supported on ${stdenv.hostPlatform.system}";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "tabnine";
|
||||
inherit (sources) version;
|
||||
|
||||
src = pkgs.fetchurl {
|
||||
url = "https://update.tabnine.com/bundles/${sources.version}/${platform.name}/TabNine.zip";
|
||||
inherit (platform) hash;
|
||||
};
|
||||
|
||||
dontBuild = true;
|
||||
|
||||
# Work around the "unpacker appears to have produced no directories"
|
||||
# case that happens when the archive doesn't have a subdirectory.
|
||||
sourceRoot = ".";
|
||||
|
||||
nativeBuildInputs = [ pkgs.unzip ];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -Dm755 TabNine $out/bin/TabNine
|
||||
install -Dm755 TabNine-deep-cloud $out/bin/TabNine-deep-cloud
|
||||
install -Dm755 TabNine-deep-local $out/bin/TabNine-deep-local
|
||||
install -Dm755 WD-TabNine $out/bin/WD-TabNine
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
platform = platform.name;
|
||||
updateScript = ./update.sh;
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://tabnine.com";
|
||||
description = "Smart Compose for code that uses deep learning to help you write code faster";
|
||||
license = licenses.unfree;
|
||||
platforms = builtins.attrNames sources.platforms;
|
||||
};
|
||||
}
|
17
packages/tabnine/sources.json
Normal file
17
packages/tabnine/sources.json
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"version": "4.64.0",
|
||||
"platforms": {
|
||||
"x86_64-linux": {
|
||||
"name": "x86_64-unknown-linux-musl",
|
||||
"hash": "sha256-AruVHP8UweT2zyOHphanvLFwOAsHiK/u98jL9axeQTI="
|
||||
},
|
||||
"aarch64-darwin": {
|
||||
"name": "aarch64-apple-darwin",
|
||||
"hash": "sha256-p06j62PaypAyeQEoFwntKQ6qSRT8Gi4NZ/Tqw+V4Ms4="
|
||||
},
|
||||
"x86_64-darwin": {
|
||||
"name": "x86_64-apple-darwin",
|
||||
"hash": "sha256-7wFdY0AzaHNLxlrQxfl55BWVcvGeqCa0dTM2zMgCK8Y="
|
||||
}
|
||||
}
|
||||
}
|
44
packages/tabnine/update.sh
Executable file
44
packages/tabnine/update.sh
Executable file
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curlMinimal jq
|
||||
#shellcheck shell=bash
|
||||
|
||||
# Based on: https://github.com/NixOS/nixpkgs/blob/91a00709aebb3602f172a0bf47ba1ef013e34835/pkgs/development/tools/tabnine/update.sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
|
||||
function prefetch-sri() {
|
||||
nix-prefetch-url "$1" 2>/dev/null |
|
||||
xargs nix --experimental-features nix-command hash to-sri --type sha256
|
||||
}
|
||||
|
||||
declare -A platforms=(
|
||||
[x86_64-unknown-linux-musl]="x86_64-linux"
|
||||
[x86_64-apple-darwin]="x86_64-darwin"
|
||||
[aarch64-apple-darwin]="aarch64-darwin"
|
||||
)
|
||||
|
||||
old_version="$(jq -r '.version' "$SCRIPT_DIR/sources.json")"
|
||||
new_version="$(curl -sS https://update.tabnine.com/bundles/version)"
|
||||
|
||||
echo "Updating $old_version -> $new_version"
|
||||
|
||||
sources_tmp="$(mktemp)"
|
||||
trap 'rm -f "$sources_tmp"' EXIT
|
||||
|
||||
cat <<EOF >"$sources_tmp"
|
||||
{
|
||||
"version": "$new_version",
|
||||
"platforms": {}
|
||||
}
|
||||
EOF
|
||||
|
||||
for platform in "${!platforms[@]}"; do
|
||||
url="https://update.tabnine.com/bundles/${new_version}/${platform}/TabNine.zip"
|
||||
hash="$(prefetch-sri "$url")"
|
||||
nix_platform="${platforms[$platform]}"
|
||||
cat <<<"$(jq --arg nix_platform "$nix_platform" --arg platform "$platform" --arg hash "$hash" '.platforms += {($nix_platform): {name: $platform, hash: $hash}}' "$sources_tmp")" >"$sources_tmp"
|
||||
done
|
||||
|
||||
cp "$sources_tmp" "$SCRIPT_DIR/sources.json"
|
Loading…
Reference in a new issue