mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 00:12:56 +00:00
Let-float various fromJSON calls to avoid repeated JSON reading/parsing
Some of these were read/parsed dozens of times in a `nix search` invocation, and in particular the MELPA recipes archive (3 MiB) was read 4 times.
This commit is contained in:
parent
04742b2737
commit
8d2a765adf
@ -23,6 +23,11 @@ formats commits for you.
|
||||
|
||||
*/
|
||||
|
||||
let
|
||||
# Read ./recipes-archive-melpa.json in an outer let to make sure we only do this once.
|
||||
defaultArchive = builtins.fromJSON (builtins.readFile ./recipes-archive-melpa.json);
|
||||
in
|
||||
|
||||
{ lib, pkgs }: variant: self:
|
||||
let
|
||||
dontConfigure = pkg:
|
||||
@ -57,7 +62,7 @@ let
|
||||
if pkg != null then dontConfigure (externalSrc pkg pkgs.rtags)
|
||||
else null;
|
||||
|
||||
generateMelpa = lib.makeOverridable ({ archiveJson ? ./recipes-archive-melpa.json
|
||||
generateMelpa = lib.makeOverridable ({ archiveJson ? defaultArchive
|
||||
}:
|
||||
let
|
||||
inherit (import ./libgenerated.nix lib self) melpaDerivation;
|
||||
@ -66,7 +71,7 @@ let
|
||||
(s: s != null)
|
||||
(map
|
||||
(melpaDerivation variant)
|
||||
(lib.importJSON archiveJson)
|
||||
(if builtins.isList archiveJson then archiveJson else lib.importJSON archiveJson)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -1,3 +1,10 @@
|
||||
let
|
||||
# `ides.json` is handwritten and contains information that doesn't change across updates, like maintainers and other metadata
|
||||
# `versions.json` contains everything generated/needed by the update script version numbers, build numbers and tarball hashes
|
||||
ideInfo = builtins.fromJSON (builtins.readFile ./bin/ides.json);
|
||||
versions = builtins.fromJSON (builtins.readFile ./bin/versions.json);
|
||||
in
|
||||
|
||||
{ lib
|
||||
, stdenv
|
||||
, callPackage
|
||||
@ -30,10 +37,6 @@
|
||||
let
|
||||
inherit (stdenv.hostPlatform) system;
|
||||
|
||||
# `ides.json` is handwritten and contains information that doesn't change across updates, like maintainers and other metadata
|
||||
# `versions.json` contains everything generated/needed by the update script version numbers, build numbers and tarball hashes
|
||||
ideInfo = lib.importJSON ./bin/ides.json;
|
||||
versions = lib.importJSON ./bin/versions.json;
|
||||
products = versions.${system} or (throw "Unsupported system: ${system}");
|
||||
|
||||
package = if stdenv.isDarwin then ./bin/darwin.nix else ./bin/linux.nix;
|
||||
|
@ -1,7 +1,7 @@
|
||||
{ lib }:
|
||||
|
||||
let
|
||||
sources = lib.importJSON ./sources.json;
|
||||
sources = import ./sources.nix;
|
||||
in
|
||||
{
|
||||
jdk-hotspot = import ./jdk-darwin-base.nix { sourcePerArch = sources.openjdk11.mac.jdk.hotspot; };
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
let
|
||||
variant = if stdenv.hostPlatform.isMusl then "alpine_linux" else "linux";
|
||||
sources = lib.importJSON ./sources.json;
|
||||
sources = import ./sources.nix;
|
||||
in
|
||||
{
|
||||
jdk-hotspot = import ./jdk-linux-base.nix { sourcePerArch = sources.openjdk11.${variant}.jdk.hotspot; };
|
||||
|
@ -1,7 +1,7 @@
|
||||
{ lib }:
|
||||
|
||||
let
|
||||
sources = lib.importJSON ./sources.json;
|
||||
sources = import ./sources.nix;
|
||||
in
|
||||
{
|
||||
jdk-hotspot = import ./jdk-darwin-base.nix { sourcePerArch = sources.openjdk13.mac.jdk.hotspot; knownVulnerabilities = ["Support ended"]; };
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
let
|
||||
variant = if stdenv.hostPlatform.isMusl then "alpine_linux" else "linux";
|
||||
sources = lib.importJSON ./sources.json;
|
||||
sources = import ./sources.nix;
|
||||
in
|
||||
{
|
||||
jdk-hotspot = import ./jdk-linux-base.nix { sourcePerArch = sources.openjdk13.${variant}.jdk.hotspot; knownVulnerabilities = ["Support ended"]; };
|
||||
|
@ -1,7 +1,7 @@
|
||||
{ lib }:
|
||||
|
||||
let
|
||||
sources = lib.importJSON ./sources.json;
|
||||
sources = import ./sources.nix;
|
||||
in
|
||||
{
|
||||
jdk-hotspot = import ./jdk-darwin-base.nix { sourcePerArch = sources.openjdk14.mac.jdk.hotspot; knownVulnerabilities = ["Support ended"]; };
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
let
|
||||
variant = if stdenv.hostPlatform.isMusl then "alpine_linux" else "linux";
|
||||
sources = lib.importJSON ./sources.json;
|
||||
sources = import ./sources.nix;
|
||||
in
|
||||
{
|
||||
jdk-hotspot = import ./jdk-linux-base.nix { sourcePerArch = sources.openjdk14.${variant}.jdk.hotspot; knownVulnerabilities = ["Support ended"]; };
|
||||
|
@ -1,7 +1,7 @@
|
||||
{ lib }:
|
||||
|
||||
let
|
||||
sources = lib.importJSON ./sources.json;
|
||||
sources = import ./sources.nix;
|
||||
in
|
||||
{
|
||||
jdk-hotspot = import ./jdk-darwin-base.nix { sourcePerArch = sources.openjdk15.mac.jdk.hotspot; knownVulnerabilities = [ "Support ended" ]; };
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
let
|
||||
variant = if stdenv.hostPlatform.isMusl then "alpine_linux" else "linux";
|
||||
sources = lib.importJSON ./sources.json;
|
||||
sources = import ./sources.nix;
|
||||
in
|
||||
{
|
||||
jdk-hotspot = import ./jdk-linux-base.nix { sourcePerArch = sources.openjdk15.${variant}.jdk.hotspot; knownVulnerabilities = [ "Support ended" ]; };
|
||||
|
@ -1,7 +1,7 @@
|
||||
{ lib }:
|
||||
|
||||
let
|
||||
sources = lib.importJSON ./sources.json;
|
||||
sources = import ./sources.nix;
|
||||
in
|
||||
{
|
||||
jdk-hotspot = import ./jdk-darwin-base.nix { sourcePerArch = sources.openjdk16.mac.jdk.hotspot; knownVulnerabilities = [ "Support ended" ]; };
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
let
|
||||
variant = if stdenv.hostPlatform.isMusl then "alpine_linux" else "linux";
|
||||
sources = lib.importJSON ./sources.json;
|
||||
sources = import ./sources.nix;
|
||||
in
|
||||
{
|
||||
jdk-hotspot = import ./jdk-linux-base.nix { sourcePerArch = sources.openjdk16.${variant}.jdk.hotspot; knownVulnerabilities = [ "Support ended" ]; };
|
||||
|
@ -1,7 +1,7 @@
|
||||
{ lib }:
|
||||
|
||||
let
|
||||
sources = lib.importJSON ./sources.json;
|
||||
sources = import ./sources.nix;
|
||||
in
|
||||
{
|
||||
jdk-hotspot = import ./jdk-darwin-base.nix { sourcePerArch = sources.openjdk17.mac.jdk.hotspot; };
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
let
|
||||
variant = if stdenv.hostPlatform.isMusl then "alpine_linux" else "linux";
|
||||
sources = lib.importJSON ./sources.json;
|
||||
sources = import ./sources.nix;
|
||||
in
|
||||
{
|
||||
jdk-hotspot = import ./jdk-linux-base.nix { sourcePerArch = sources.openjdk17.${variant}.jdk.hotspot; };
|
||||
|
@ -1,7 +1,7 @@
|
||||
{ lib }:
|
||||
|
||||
let
|
||||
sources = lib.importJSON ./sources.json;
|
||||
sources = import ./sources.nix;
|
||||
in
|
||||
{
|
||||
jdk-hotspot = import ./jdk-darwin-base.nix { sourcePerArch = sources.openjdk8.mac.jdk.hotspot; };
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
let
|
||||
variant = if stdenv.hostPlatform.isMusl then "alpine_linux" else "linux";
|
||||
sources = lib.importJSON ./sources.json;
|
||||
sources = import ./sources.nix;
|
||||
in
|
||||
{
|
||||
jdk-hotspot = import ./jdk-linux-base.nix { sourcePerArch = sources.openjdk8.${variant}.jdk.hotspot; };
|
||||
|
1
pkgs/development/compilers/adoptopenjdk-bin/sources.nix
Normal file
1
pkgs/development/compilers/adoptopenjdk-bin/sources.nix
Normal file
@ -0,0 +1 @@
|
||||
builtins.fromJSON (builtins.readFile ./sources.json)
|
@ -1,8 +1,11 @@
|
||||
let
|
||||
infoJson = builtins.fromJSON (builtins.readFile ./info.json);
|
||||
in
|
||||
|
||||
{ lib, callPackage }:
|
||||
|
||||
let
|
||||
mkElectron = callPackage ./generic.nix { };
|
||||
infoJson = builtins.fromJSON (builtins.readFile ./info.json);
|
||||
in
|
||||
lib.mapAttrs' (majorVersion: info:
|
||||
lib.nameValuePair
|
||||
|
@ -1,6 +1,8 @@
|
||||
let
|
||||
versions = builtins.fromJSON (builtins.readFile ./versions.json);
|
||||
in
|
||||
{ callPackage, lib, ... }:
|
||||
let
|
||||
versions = lib.importJSON ./versions.json;
|
||||
latestVersion = lib.last (builtins.sort lib.versionOlder (builtins.attrNames versions));
|
||||
escapeVersion = builtins.replaceStrings [ "." ] [ "_" ];
|
||||
packages = lib.mapAttrs'
|
||||
|
@ -1,7 +1,10 @@
|
||||
let
|
||||
modelSpecs = (builtins.fromJSON (builtins.readFile ./models.json));
|
||||
in
|
||||
|
||||
{ lib, stdenvNoCC, fetchurl }:
|
||||
|
||||
let
|
||||
modelSpecs = (builtins.fromJSON (builtins.readFile ./models.json));
|
||||
withCodeAsKey = f: { code, ... }@attrs: lib.nameValuePair code (f attrs);
|
||||
mkModelPackage = { name, code, version, url, checksum }:
|
||||
stdenvNoCC.mkDerivation {
|
||||
|
@ -1,7 +1,10 @@
|
||||
let
|
||||
allKernels = builtins.fromJSON (builtins.readFile ./kernels-org.json);
|
||||
in
|
||||
|
||||
{ branch, lib, fetchurl, fetchzip, buildLinux, ... } @ args:
|
||||
|
||||
let
|
||||
allKernels = builtins.fromJSON (builtins.readFile ./kernels-org.json);
|
||||
thisKernel = allKernels.${branch};
|
||||
inherit (thisKernel) version;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user