Compare commits
3 Commits
8832d0a4a4
...
6486b91e34
Author | SHA1 | Date | |
---|---|---|---|
6486b91e34 | |||
7f7fc70b27 | |||
1bfb879c49 |
24
.github/workflows/update-jetbrains.yml
vendored
Normal file
24
.github/workflows/update-jetbrains.yml
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
name: "Update Jetbrains plugins"
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '00 2 * * *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v2.3.3
|
||||||
|
- name: Install nix
|
||||||
|
uses: cachix/install-nix-action@v11
|
||||||
|
with:
|
||||||
|
nix_path: "${{ matrix.nixPath }}"
|
||||||
|
- name: Show nixpkgs version
|
||||||
|
run: nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
|
||||||
|
- name: Generate package list
|
||||||
|
# TODO switch to default nixpkgs channel once nix-build-uncached 1.0.0 is in stable
|
||||||
|
run: nix run -I 'nixpkgs=channel:nixos-unstable' nixpkgs.nix-build-uncached -c nix-build-uncached ci.nix -A cacheOutputs
|
||||||
|
- name: Trigger NUR update
|
||||||
|
if: ${{ matrix.nurRepo != '<YOUR_REPO_NAME>' }}
|
||||||
|
run: curl -XPOST "https://nur-update.herokuapp.com/update?repo=${{ matrix.nurRepo }}"
|
||||||
|
|
@ -27,6 +27,10 @@ PRODUCT_CODE = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PACKAGE_RE = re.compile("[^0-9A-Za-z._-]")
|
||||||
|
HTML_RE = re.compile("<[^>]+/?>")
|
||||||
|
|
||||||
|
|
||||||
def to_slug(name):
|
def to_slug(name):
|
||||||
slug = name.replace(" ", "-").lstrip(".")
|
slug = name.replace(" ", "-").lstrip(".")
|
||||||
for char in ",/;'\\<>:\"|!@#$%^&*()":
|
for char in ",/;'\\<>:\"|!@#$%^&*()":
|
||||||
@ -59,18 +63,15 @@ class Build:
|
|||||||
return self.code + "-" + self.version
|
return self.code + "-" + self.version
|
||||||
|
|
||||||
|
|
||||||
PACKAGE_RE = re.compile("[^0-9A-Za-z._-]")
|
|
||||||
HTML_RE = re.compile("<[^>]+/?>")
|
|
||||||
|
|
||||||
|
|
||||||
class Plugin:
|
class Plugin:
|
||||||
def __init__(self, data, category=None):
|
def __init__(self, data, build, category=None):
|
||||||
|
self.build = build
|
||||||
self.category = category
|
self.category = category
|
||||||
self.name = data.find("name").text
|
self.name = data.find("name").text
|
||||||
self.id = data.find("id").text
|
self.xml_id = data.find("id").text
|
||||||
self._description = data.find("description").text
|
self._description = data.find("description").text
|
||||||
self.url = data.get("url") or data.find("vendor").get("url")
|
self.url = data.get("url") or data.find("vendor").get("url")
|
||||||
self.version = data.find("version").text
|
self.version = data.find("version").text.replace(" ", "-")
|
||||||
self.slug = to_slug(self.name)
|
self.slug = to_slug(self.name)
|
||||||
self.orig_slug = self.slug
|
self.orig_slug = self.slug
|
||||||
|
|
||||||
@ -84,7 +85,7 @@ class Plugin:
|
|||||||
def description(self):
|
def description(self):
|
||||||
return re.sub(HTML_RE, "", self._description or "").strip()
|
return re.sub(HTML_RE, "", self._description or "").strip()
|
||||||
|
|
||||||
def download_url(self, build, deref=True):
|
def get_download_url(self, deref=True):
|
||||||
"""
|
"""
|
||||||
Provides the ZIP download URL for this plugin.
|
Provides the ZIP download URL for this plugin.
|
||||||
|
|
||||||
@ -94,18 +95,52 @@ class Plugin:
|
|||||||
(which it is by default). However, this comes at the cost of requiring
|
(which it is by default). However, this comes at the cost of requiring
|
||||||
an HTTP request.
|
an HTTP request.
|
||||||
"""
|
"""
|
||||||
id = urllib.parse.quote(self.id)
|
id = urllib.parse.quote(self.xml_id)
|
||||||
url = f"https://plugins.jetbrains.com/pluginManager?action=download&id={id}&build={build}"
|
url = f"https://plugins.jetbrains.com/pluginManager?action=download&id={id}&build={self.build}"
|
||||||
if deref:
|
if deref:
|
||||||
res = requests.get(url, allow_redirects=not deref)
|
res = requests.get(url, allow_redirects=not deref)
|
||||||
url = "https://plugins.jetbrains.com" + re.sub(
|
url = "https://plugins.jetbrains.com" + re.sub(
|
||||||
"\?.*$", "", res.headers["location"]
|
"\?.*$", "", res.headers["location"]
|
||||||
)
|
)
|
||||||
|
self.jetbrains_url = url
|
||||||
if url.endswith("external"):
|
if url.endswith("external"):
|
||||||
res = requests.get(url, allow_redirects=not deref)
|
res = requests.get(url, allow_redirects=not deref)
|
||||||
url = res.headers["location"]
|
url = res.headers["location"]
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
def fetch_external(self, update_only=False):
|
||||||
|
"""
|
||||||
|
Performs network calls to update this plugin with information that
|
||||||
|
cannot be performed from the public XML API.
|
||||||
|
|
||||||
|
Additional attributes provided after this method:
|
||||||
|
|
||||||
|
download_url : the plugin download location
|
||||||
|
sha : the SHA256 of the download source
|
||||||
|
|
||||||
|
If update_only is true, a full update is performed, also providing:
|
||||||
|
|
||||||
|
id : the plugin integer ID
|
||||||
|
license_url : the plugin license URL
|
||||||
|
license : the Nixpkgs license attribute
|
||||||
|
"""
|
||||||
|
self.download_url = self.get_download_url(deref=True)
|
||||||
|
self.sha = prefetch(self, self.build, self.download_url)
|
||||||
|
|
||||||
|
if update_only:
|
||||||
|
return
|
||||||
|
|
||||||
|
self.id = self.jetbrains_url.split("/")[4]
|
||||||
|
res = requests.get(
|
||||||
|
f"https://plugins.jetbrains.com/api/plugins/{self.id}"
|
||||||
|
).json()
|
||||||
|
try:
|
||||||
|
self.url = self.url or res["urls"]["sourceCodeUrl"]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
self.license_url = res["urls"]["licenseUrl"]
|
||||||
|
self.license = translate_license(self.license_url, fallback=self.url)
|
||||||
|
|
||||||
def packagename(self):
|
def packagename(self):
|
||||||
slug = re.sub(PACKAGE_RE, "", self.slug.lower()).replace(".", "-")
|
slug = re.sub(PACKAGE_RE, "", self.slug.lower()).replace(".", "-")
|
||||||
if slug[0] in "1234567890":
|
if slug[0] in "1234567890":
|
||||||
@ -128,16 +163,16 @@ def list_plugins(build):
|
|||||||
https://plugins.jetbrains.com/docs/marketplace/plugins-list.html
|
https://plugins.jetbrains.com/docs/marketplace/plugins-list.html
|
||||||
"""
|
"""
|
||||||
resp = requests.get(f"https://plugins.jetbrains.com/plugins/list/?build={build}")
|
resp = requests.get(f"https://plugins.jetbrains.com/plugins/list/?build={build}")
|
||||||
return parse_repository(resp.content)
|
return parse_repository(resp.content, build)
|
||||||
|
|
||||||
|
|
||||||
def parse_repository(content):
|
def parse_repository(content, build):
|
||||||
tree = etree.XML(content)
|
tree = etree.XML(content)
|
||||||
plugins = []
|
plugins = []
|
||||||
for cat in tree.findall("category"):
|
for cat in tree.findall("category"):
|
||||||
cat_name = cat.get("name")
|
cat_name = cat.get("name")
|
||||||
for plugin in cat.findall("idea-plugin"):
|
for plugin in cat.findall("idea-plugin"):
|
||||||
plugins.append(Plugin(plugin, cat_name))
|
plugins.append(Plugin(plugin, build, cat_name))
|
||||||
return plugins
|
return plugins
|
||||||
|
|
||||||
|
|
||||||
@ -155,7 +190,7 @@ def deduplicate(plugins):
|
|||||||
|
|
||||||
def prefetch(plugin, build, url=None):
|
def prefetch(plugin, build, url=None):
|
||||||
if not url:
|
if not url:
|
||||||
url = plugin.download_url(build)
|
url = plugin.download_url or plugin.get_download_url()
|
||||||
res = sp.run(
|
res = sp.run(
|
||||||
["nix-prefetch-url", "--name", plugin.filename(), url], capture_output=True,
|
["nix-prefetch-url", "--name", plugin.filename(), url], capture_output=True,
|
||||||
)
|
)
|
||||||
@ -164,19 +199,90 @@ def prefetch(plugin, build, url=None):
|
|||||||
return res.stdout.decode("utf-8").strip()
|
return res.stdout.decode("utf-8").strip()
|
||||||
|
|
||||||
|
|
||||||
def write_packages(outfile, plugins, build):
|
def custom_license(short, full, url, free=False):
|
||||||
builder = build.builder()
|
return f"""{{
|
||||||
|
shortName = "{short}";
|
||||||
|
fullName = "{full}";
|
||||||
|
url = "{url}";
|
||||||
|
free = {"true" if free else "false"};
|
||||||
|
}}"""
|
||||||
|
|
||||||
|
|
||||||
|
def arr(url):
|
||||||
|
return custom_license("allrightsreserved", "All Rights Reserved", url)
|
||||||
|
|
||||||
|
|
||||||
|
def translate_license(url, fallback=""):
|
||||||
|
license = url.lower()
|
||||||
|
if license == "":
|
||||||
|
print(f"no license for {fallback}", file=sys.stderr)
|
||||||
|
return arr(fallback)
|
||||||
|
# Common (license) hosts
|
||||||
|
elif "github.com" in license or "raw.githubusercontent.com" in license:
|
||||||
|
try:
|
||||||
|
owner, repo = url.split("/")[3:5]
|
||||||
|
except ValueError:
|
||||||
|
print(f"no license metadata for {url}", file=sys.stderr)
|
||||||
|
return arr(url)
|
||||||
|
res = requests.get(
|
||||||
|
f"https://api.github.com/repos/{owner}/{repo}",
|
||||||
|
headers={"Accept": "application/vnd.github.v3+json"},
|
||||||
|
).json()
|
||||||
|
try:
|
||||||
|
return translate_license(res["license"]["key"])
|
||||||
|
except (KeyError, TypeError):
|
||||||
|
print(f"no license metadata for {url}", file=sys.stderr)
|
||||||
|
return arr(url)
|
||||||
|
elif "opensource.org" in license:
|
||||||
|
os_license = license.rstrip("/").split("/")[-1]
|
||||||
|
if os_license == "alphabetical":
|
||||||
|
# Doesn't actually have a license, it's the listing page
|
||||||
|
return arr(fallback)
|
||||||
|
return translate_license(os_license)
|
||||||
|
# Actual translations now
|
||||||
|
elif "apache.org/licenses/license-2.0" in license or "apache-2.0" in license:
|
||||||
|
return "lib.licenses.asl20"
|
||||||
|
elif "artistic-2" in license:
|
||||||
|
return "lib.licenses.artistic2"
|
||||||
|
elif "bsd-2-clause" in license:
|
||||||
|
return "lib.licenses.bsd2"
|
||||||
|
elif "bsd-3-clause" in license:
|
||||||
|
return "lib.licenses.bsd3"
|
||||||
|
elif "eclipse.org/legal/epl-2.0" in license:
|
||||||
|
return "lib.licenses.epl20"
|
||||||
|
elif "gpl-3.0" in license:
|
||||||
|
return "lib.licenses.gpl3Only"
|
||||||
|
elif "mit" in license:
|
||||||
|
return "lib.licenses.mit"
|
||||||
|
elif "osd" in license:
|
||||||
|
return "lib.licenses.free"
|
||||||
|
elif "other" == license:
|
||||||
|
return arr(fallback)
|
||||||
|
# Custom known licenses
|
||||||
|
elif "plugins.jetbrains.com/legal/terms-of-use" in license:
|
||||||
|
return custom_license(
|
||||||
|
"jetbrains", "Jetbrains Plugin Marketplace Agreement", license
|
||||||
|
)
|
||||||
|
# Fallback
|
||||||
|
else:
|
||||||
|
print(f"unrecognised license {license}", file=sys.stderr)
|
||||||
|
return arr(license)
|
||||||
|
|
||||||
|
|
||||||
|
def write_packages(outfile, plugins):
|
||||||
|
builder = plugins[0].build.builder() or ""
|
||||||
outfile.write("{callPackage}:\n{")
|
outfile.write("{callPackage}:\n{")
|
||||||
|
|
||||||
for plugin in plugins:
|
for i, plugin in enumerate(plugins):
|
||||||
src_url = plugin.download_url(build, deref=True)
|
print(f"{i:04} {plugin.packagename()}")
|
||||||
src_ext = os.path.splitext(src_url)[-1]
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sha = prefetch(plugin, build, src_url)
|
plugin.fetch_external()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print(e, file=sys.stderr)
|
print(e, file=sys.stderr)
|
||||||
continue
|
continue
|
||||||
|
src_url = plugin.download_url
|
||||||
|
src_ext = os.path.splitext(src_url)[-1]
|
||||||
|
sha = plugin.sha
|
||||||
|
|
||||||
build_inputs = []
|
build_inputs = []
|
||||||
if src_ext == ".zip":
|
if src_ext == ".zip":
|
||||||
@ -186,7 +292,7 @@ def write_packages(outfile, plugins, build):
|
|||||||
# internal and external plugins; need to find some way to resolve them
|
# internal and external plugins; need to find some way to resolve them
|
||||||
requires = []
|
requires = []
|
||||||
# TODO: Licenses are actually on the website, but aren't provided in the API
|
# TODO: Licenses are actually on the website, but aren't provided in the API
|
||||||
license = "lib.licenses.free"
|
license = plugin.license
|
||||||
|
|
||||||
call_args = [str(builder), "fetchurl", "lib"]
|
call_args = [str(builder), "fetchurl", "lib"]
|
||||||
for binput in build_inputs:
|
for binput in build_inputs:
|
||||||
@ -197,7 +303,7 @@ def write_packages(outfile, plugins, build):
|
|||||||
{plugin.packagename()} = callPackage ({{ {", ".join(sorted(call_args))} }}: {builder} {{
|
{plugin.packagename()} = callPackage ({{ {", ".join(sorted(call_args))} }}: {builder} {{
|
||||||
pname = "{plugin.slug}";
|
pname = "{plugin.slug}";
|
||||||
plugname = "{plugin.name}";
|
plugname = "{plugin.name}";
|
||||||
plugid = "{plugin.id}";
|
plugid = "{plugin.xml_id}";
|
||||||
version = "{plugin.version}";
|
version = "{plugin.version}";
|
||||||
src = fetchurl {{
|
src = fetchurl {{
|
||||||
url = "{src_url}";
|
url = "{src_url}";
|
||||||
@ -227,6 +333,7 @@ def main():
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-o", "--out", type=str, help="File to write plugins to",
|
"-o", "--out", type=str, help="File to write plugins to",
|
||||||
)
|
)
|
||||||
|
parser.add_argument("-O", "--offset", type=int, help="Offset number of packages")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"package",
|
"package",
|
||||||
metavar="PACKAGE",
|
metavar="PACKAGE",
|
||||||
@ -241,15 +348,17 @@ def main():
|
|||||||
plugins.sort(key=lambda p: p.slug)
|
plugins.sort(key=lambda p: p.slug)
|
||||||
deduplicate(plugins)
|
deduplicate(plugins)
|
||||||
|
|
||||||
|
if args.offset:
|
||||||
|
plugins = plugins[args.offset :]
|
||||||
if args.number:
|
if args.number:
|
||||||
plugins = plugins[: args.number]
|
plugins = plugins[: args.number]
|
||||||
|
|
||||||
print(f"Generating packages for {len(plugins)} plugins", file=sys.stderr)
|
print(f"Generating packages for {len(plugins)} plugins", file=sys.stderr)
|
||||||
if not args.out:
|
if not args.out:
|
||||||
write_packages(sys.stdout, plugins, build)
|
write_packages(sys.stdout, plugins)
|
||||||
else:
|
else:
|
||||||
with open(args.out, "w") as f:
|
with open(args.out, "w") as f:
|
||||||
write_packages(f, plugins, build)
|
write_packages(f, plugins)
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
17
default.nix
17
default.nix
@ -16,25 +16,23 @@ rec {
|
|||||||
|
|
||||||
# Alacritty with the unmerged ligature patches applied.
|
# Alacritty with the unmerged ligature patches applied.
|
||||||
alacritty-ligatures = (pkgs.alacritty.override {
|
alacritty-ligatures = (pkgs.alacritty.override {
|
||||||
# 0.6.0 requires a minimum of 1.43, and this is the only version on both
|
inherit (pkgs.rustPackages_1_45) rustPlatform;
|
||||||
# stable and unstable channels right now.
|
|
||||||
inherit (pkgs.rustPackages_1_44) rustPlatform;
|
|
||||||
}).overrideAttrs (oldAttrs: rec {
|
}).overrideAttrs (oldAttrs: rec {
|
||||||
pname = "${oldAttrs.pname}-ligatures";
|
pname = "${oldAttrs.pname}-ligatures";
|
||||||
version = "0.6.0.20201015";
|
version = "0.6.0.20201022";
|
||||||
|
|
||||||
src = pkgs.fetchFromGitHub {
|
src = pkgs.fetchFromGitHub {
|
||||||
owner = "zenixls2";
|
owner = "zenixls2";
|
||||||
repo = "alacritty";
|
repo = "alacritty";
|
||||||
fetchSubmodules = true;
|
fetchSubmodules = true;
|
||||||
rev = "30ebb4303229acbfdbbf00a84a9c46973c4e0334";
|
rev = "525fe0ea174354db7ba28de65328a0db18fd7f70";
|
||||||
sha256 = "1c0951zs1h2d6fjnxixfms3913m1c6yvgmcizgd9gfgx59ghpafi";
|
sha256 = "1j8mrslii7bw721bkgaqxm9ldrm5f01cil55dfjn7ziwz3xjvqvx";
|
||||||
};
|
};
|
||||||
|
|
||||||
cargoDeps = oldAttrs.cargoDeps.overrideAttrs (pkgs.lib.const {
|
cargoDeps = oldAttrs.cargoDeps.overrideAttrs (pkgs.lib.const {
|
||||||
name = "${pname}-${version}-vendor.tar.gz";
|
name = "${pname}-${version}-vendor.tar.gz";
|
||||||
inherit src;
|
inherit src;
|
||||||
outputHash = "1gi3bvcra56maxcz1a6i1nmzdrfa4mhx6pn1xjbrifv7c6jlxard";
|
outputHash = "11kj2hr9wkq1zq13ml561i0i0h40d34iwqy0b8apn9ij8pdp0b37";
|
||||||
});
|
});
|
||||||
|
|
||||||
ligatureInputs = [
|
ligatureInputs = [
|
||||||
@ -80,6 +78,11 @@ rec {
|
|||||||
clionWithPlugins = clionPlugins.jetbrainsWithPlugins;
|
clionWithPlugins = clionPlugins.jetbrainsWithPlugins;
|
||||||
ideaCommunityWithPlugins = ideaCommunityPlugins.jetbrainsWithPlugins;
|
ideaCommunityWithPlugins = ideaCommunityPlugins.jetbrainsWithPlugins;
|
||||||
ideaUltimateWithPlugins = ideaUltimatePlugins.jetbrainsWithPlugins;
|
ideaUltimateWithPlugins = ideaUltimatePlugins.jetbrainsWithPlugins;
|
||||||
|
|
||||||
|
test = ideaUltimateWithPlugins (jpkgs: [
|
||||||
|
jpkgs._360-fireline-plugin # zip
|
||||||
|
jpkgs._3dsmaxpy-support # jar
|
||||||
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
libhl = pkgs.callPackage ./pkgs/development/libraries/libhl { };
|
libhl = pkgs.callPackage ./pkgs/development/libraries/libhl { };
|
||||||
|
6154
pkgs/applications/editors/jetbrains/idea-generated.nix
Normal file
6154
pkgs/applications/editors/jetbrains/idea-generated.nix
Normal file
File diff suppressed because it is too large
Load Diff
@ -28,6 +28,8 @@ let
|
|||||||
homepage = args.src.meta.homepage;
|
homepage = args.src.meta.homepage;
|
||||||
} // optionalAttrs ((args.src.meta.description or "") != "") {
|
} // optionalAttrs ((args.src.meta.description or "") != "") {
|
||||||
description = args.src.meta.description;
|
description = args.src.meta.description;
|
||||||
|
} // optionalAttrs ((args.src.meta.license or {}) != {}) {
|
||||||
|
license = args.src.meta.license;
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
|
Loading…
Reference in New Issue
Block a user