From 00000001b4f4a57961f35ba1e0db5a4806a38ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Fri, 5 May 2023 21:39:20 +0200 Subject: [PATCH] treewide: switch builtins.fromJSON(builtins.readFile ./file.json) to lib.importJSON ./file.json #2 --- doc/build-aux/pandoc-filters/link-manpages.nix | 2 +- pkgs/applications/emulators/retroarch/cores.nix | 2 +- pkgs/applications/networking/browsers/librewolf/src.nix | 4 ++-- pkgs/build-support/flutter/default.nix | 4 ++-- pkgs/data/misc/hackage/default.nix | 2 +- pkgs/development/libraries/ndi/default.nix | 2 +- pkgs/development/tools/build-managers/scala-cli/default.nix | 2 +- pkgs/development/tools/mongosh/default.nix | 2 +- pkgs/development/tools/poetry2nix/poetry2nix/default.nix | 2 +- pkgs/development/tools/swiftpm2nix/support.nix | 2 +- pkgs/development/tools/tabnine/default.nix | 2 +- pkgs/servers/invidious/default.nix | 2 +- pkgs/servers/invidious/lsquic.nix | 2 +- pkgs/servers/invidious/videojs.nix | 4 ++-- pkgs/servers/nosql/cassandra/3.0.nix | 4 ++-- pkgs/servers/nosql/cassandra/3.11.nix | 4 ++-- pkgs/servers/nosql/cassandra/4.nix | 4 ++-- pkgs/tools/admin/google-cloud-sdk/components.nix | 2 +- pkgs/tools/nix/npins/default.nix | 2 +- pkgs/tools/nix/npins/source.nix | 2 +- 20 files changed, 26 insertions(+), 26 deletions(-) diff --git a/doc/build-aux/pandoc-filters/link-manpages.nix b/doc/build-aux/pandoc-filters/link-manpages.nix index ee27c5d60812..2589a7c34251 100644 --- a/doc/build-aux/pandoc-filters/link-manpages.nix +++ b/doc/build-aux/pandoc-filters/link-manpages.nix @@ -1,7 +1,7 @@ { pkgs ? import ../../.. {} }: let inherit (pkgs) lib; - manpageURLs = builtins.fromJSON (builtins.readFile (pkgs.path + "/doc/manpage-urls.json")); + manpageURLs = lib.importJSON (pkgs.path + "/doc/manpage-urls.json"); in pkgs.writeText "link-manpages.lua" '' --[[ Adds links to known man pages that aren't already in a link. diff --git a/pkgs/applications/emulators/retroarch/cores.nix b/pkgs/applications/emulators/retroarch/cores.nix index e38fe646c4c3..5da2ad763187 100644 --- a/pkgs/applications/emulators/retroarch/cores.nix +++ b/pkgs/applications/emulators/retroarch/cores.nix @@ -42,7 +42,7 @@ }: let - hashesFile = builtins.fromJSON (builtins.readFile ./hashes.json); + hashesFile = lib.importJSON ./hashes.json; getCoreSrc = core: fetchFromGitHub (builtins.getAttr core hashesFile); diff --git a/pkgs/applications/networking/browsers/librewolf/src.nix b/pkgs/applications/networking/browsers/librewolf/src.nix index 38c5dc6b593d..a2100ac2ab8b 100644 --- a/pkgs/applications/networking/browsers/librewolf/src.nix +++ b/pkgs/applications/networking/browsers/librewolf/src.nix @@ -1,5 +1,5 @@ -{ fetchurl, fetchFromGitLab }: -let src = builtins.fromJSON (builtins.readFile ./src.json); +{ lib, fetchurl, fetchFromGitLab }: +let src = lib.importJSON ./src.json; in { inherit (src) packageVersion; diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index abb1c8ac359f..66ac78534e35 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -135,11 +135,11 @@ let packageOverrideRepository = (callPackage ../../development/compilers/flutter/package-overrides { }) // customPackageOverrides; productPackages = builtins.filter (package: package.kind != "dev") (if autoDepsList - then builtins.fromJSON (builtins.readFile deps.depsListFile) + then lib.importJSON deps.depsListFile else if depsListFile == null then [ ] - else builtins.fromJSON (builtins.readFile depsListFile)); + else lib.importJSON depsListFile); in builtins.foldl' (prev: package: diff --git a/pkgs/data/misc/hackage/default.nix b/pkgs/data/misc/hackage/default.nix index 2e8c660d9472..b283f2025e0d 100644 --- a/pkgs/data/misc/hackage/default.nix +++ b/pkgs/data/misc/hackage/default.nix @@ -2,7 +2,7 @@ # and callHackage { lib, fetchurl }: let - pin = builtins.fromJSON (builtins.readFile ./pin.json); + pin = lib.importJSON ./pin.json; in fetchurl { inherit (pin) url sha256; diff --git a/pkgs/development/libraries/ndi/default.nix b/pkgs/development/libraries/ndi/default.nix index 6849c3620332..1c15455b6add 100644 --- a/pkgs/development/libraries/ndi/default.nix +++ b/pkgs/development/libraries/ndi/default.nix @@ -1,7 +1,7 @@ { lib, stdenv, requireFile, avahi, obs-studio-plugins }: let - versionJSON = builtins.fromJSON (builtins.readFile ./version.json); + versionJSON = lib.importJSON ./version.json; in stdenv.mkDerivation rec { pname = "ndi"; diff --git a/pkgs/development/tools/build-managers/scala-cli/default.nix b/pkgs/development/tools/build-managers/scala-cli/default.nix index 9381922a5fb5..3b509f03c5ff 100644 --- a/pkgs/development/tools/build-managers/scala-cli/default.nix +++ b/pkgs/development/tools/build-managers/scala-cli/default.nix @@ -12,7 +12,7 @@ let pname = "scala-cli"; - sources = builtins.fromJSON (builtins.readFile ./sources.json); + sources = lib.importJSON ./sources.json; inherit (sources) version assets; platforms = builtins.attrNames assets; diff --git a/pkgs/development/tools/mongosh/default.nix b/pkgs/development/tools/mongosh/default.nix index 0bc4aa24a1a8..56e2e2e8e421 100644 --- a/pkgs/development/tools/mongosh/default.nix +++ b/pkgs/development/tools/mongosh/default.nix @@ -6,7 +6,7 @@ }: let - source = builtins.fromJSON (builtins.readFile ./source.json); + source = lib.importJSON ./source.json; in buildNpmPackage { pname = "mongosh"; diff --git a/pkgs/development/tools/poetry2nix/poetry2nix/default.nix b/pkgs/development/tools/poetry2nix/poetry2nix/default.nix index 16d443cbd5cc..fe888c60cd2c 100644 --- a/pkgs/development/tools/poetry2nix/poetry2nix/default.nix +++ b/pkgs/development/tools/poetry2nix/poetry2nix/default.nix @@ -17,7 +17,7 @@ let toPluginAble = (import ./plugins.nix { inherit pkgs lib; }).toPluginAble; # List of known build systems that are passed through from nixpkgs unmodified - knownBuildSystems = builtins.fromJSON (builtins.readFile ./known-build-systems.json); + knownBuildSystems = lib.importJSON ./known-build-systems.json; nixpkgsBuildSystems = lib.subtractLists [ "poetry" "poetry-core" ] knownBuildSystems; mkInputAttrs = diff --git a/pkgs/development/tools/swiftpm2nix/support.nix b/pkgs/development/tools/swiftpm2nix/support.nix index 3c8e597f25ea..9b944a133daa 100644 --- a/pkgs/development/tools/swiftpm2nix/support.nix +++ b/pkgs/development/tools/swiftpm2nix/support.nix @@ -19,7 +19,7 @@ in rec { # Make packaging helpers from swiftpm2nix generated output. helpers = generated: let inherit (import generated) workspaceStateFile hashes; - workspaceState = builtins.fromJSON (builtins.readFile workspaceStateFile); + workspaceState = lib.importJSON workspaceStateFile; pinFile = mkPinFile workspaceState; in rec { diff --git a/pkgs/development/tools/tabnine/default.nix b/pkgs/development/tools/tabnine/default.nix index 9b2616e7ebd7..fcd00726ba77 100644 --- a/pkgs/development/tools/tabnine/default.nix +++ b/pkgs/development/tools/tabnine/default.nix @@ -1,6 +1,6 @@ { stdenv, lib, fetchurl, unzip }: let - sources = builtins.fromJSON (builtins.readFile ./sources.json); + sources = lib.importJSON ./sources.json; platform = if (builtins.hasAttr stdenv.hostPlatform.system sources.platforms) then builtins.getAttr (stdenv.hostPlatform.system) sources.platforms diff --git a/pkgs/servers/invidious/default.nix b/pkgs/servers/invidious/default.nix index b3b0d2d47ad0..d6d9ec17363e 100644 --- a/pkgs/servers/invidious/default.nix +++ b/pkgs/servers/invidious/default.nix @@ -12,7 +12,7 @@ let # * update lsquic and boringssl if necessarry, lsquic.cr depends on # the same version of lsquic and lsquic requires the boringssl # commit mentioned in its README - versions = builtins.fromJSON (builtins.readFile ./versions.json); + versions = lib.importJSON ./versions.json; in crystal.buildCrystalPackage rec { pname = "invidious"; diff --git a/pkgs/servers/invidious/lsquic.nix b/pkgs/servers/invidious/lsquic.nix index c2c88dd8e3b8..c9cdd9958ede 100644 --- a/pkgs/servers/invidious/lsquic.nix +++ b/pkgs/servers/invidious/lsquic.nix @@ -1,6 +1,6 @@ { lib, boringssl, stdenv, fetchgit, fetchFromGitHub, fetchurl, cmake, zlib, perl, libevent }: let - versions = builtins.fromJSON (builtins.readFile ./versions.json); + versions = lib.importJSON ./versions.json; fetchGitilesPatch = { name, url, sha256 }: fetchurl { diff --git a/pkgs/servers/invidious/videojs.nix b/pkgs/servers/invidious/videojs.nix index e4470793e51e..4016f8e1258d 100644 --- a/pkgs/servers/invidious/videojs.nix +++ b/pkgs/servers/invidious/videojs.nix @@ -1,7 +1,7 @@ -{ stdenvNoCC, cacert, crystal, openssl, pkg-config, invidious }: +{ lib, stdenvNoCC, cacert, crystal, openssl, pkg-config, invidious }: let - versions = builtins.fromJSON (builtins.readFile ./versions.json); + versions = lib.importJSON ./versions.json; in stdenvNoCC.mkDerivation { name = "videojs"; diff --git a/pkgs/servers/nosql/cassandra/3.0.nix b/pkgs/servers/nosql/cassandra/3.0.nix index 9c62901a4808..ce2da3391be1 100644 --- a/pkgs/servers/nosql/cassandra/3.0.nix +++ b/pkgs/servers/nosql/cassandra/3.0.nix @@ -1,7 +1,7 @@ -{ callPackage, ... } @ args: +{ callPackage, lib, ... } @ args: callPackage ./generic.nix ( args - // builtins.fromJSON (builtins.readFile ./3.0.json) + // lib.importJSON ./3.0.json // { generation = "3_0"; }) diff --git a/pkgs/servers/nosql/cassandra/3.11.nix b/pkgs/servers/nosql/cassandra/3.11.nix index ffb29743405b..695478f05030 100644 --- a/pkgs/servers/nosql/cassandra/3.11.nix +++ b/pkgs/servers/nosql/cassandra/3.11.nix @@ -1,7 +1,7 @@ -{ callPackage, ... } @ args: +{ callPackage, lib, ... } @ args: callPackage ./generic.nix ( args - // builtins.fromJSON (builtins.readFile ./3.11.json) + // lib.importJSON ./3.11.json // { generation = "3_11"; }) diff --git a/pkgs/servers/nosql/cassandra/4.nix b/pkgs/servers/nosql/cassandra/4.nix index 0a96e2579035..5674d4866475 100644 --- a/pkgs/servers/nosql/cassandra/4.nix +++ b/pkgs/servers/nosql/cassandra/4.nix @@ -1,8 +1,8 @@ # GENERATED BY update.sh -{ callPackage, ... } @ args: +{ callPackage, lib, ... } @ args: callPackage ./generic.nix ( args - // builtins.fromJSON (builtins.readFile ./4.json) + // lib.importJSON ./4.json // { generation = "4"; }) diff --git a/pkgs/tools/admin/google-cloud-sdk/components.nix b/pkgs/tools/admin/google-cloud-sdk/components.nix index 4f13bca3a20c..f4e5bca7307f 100644 --- a/pkgs/tools/admin/google-cloud-sdk/components.nix +++ b/pkgs/tools/admin/google-cloud-sdk/components.nix @@ -38,7 +38,7 @@ let # A description of all available google-cloud-sdk components. # It's a JSON file with a list of components, along with some metadata - snapshot = builtins.fromJSON (builtins.readFile snapshotPath); + snapshot = lib.importJSON snapshotPath; # Generate a snapshot file for a single component. It has the same format as # `snapshot`, but only contains a single component. These files are diff --git a/pkgs/tools/nix/npins/default.nix b/pkgs/tools/nix/npins/default.nix index aff959f3d5a8..96f2f5548884 100644 --- a/pkgs/tools/nix/npins/default.nix +++ b/pkgs/tools/nix/npins/default.nix @@ -15,7 +15,7 @@ let runtimePath = lib.makeBinPath [ nix nix-prefetch-git git ]; - sources = (builtins.fromJSON (builtins.readFile ./sources.json)).pins; + sources = (lib.importJSON ./sources.json).pins; in rustPlatform.buildRustPackage rec { pname = "npins"; version = src.version; diff --git a/pkgs/tools/nix/npins/source.nix b/pkgs/tools/nix/npins/source.nix index 8c9e47204afd..49046d8dd3c6 100644 --- a/pkgs/tools/nix/npins/source.nix +++ b/pkgs/tools/nix/npins/source.nix @@ -3,7 +3,7 @@ # Usage: # ```nix # let -# sources = builtins.fromJSON (builtins.readFile ./sources.json); +# sources = lib.importJSON ./sources.json; # in mkMyDerivation rec { # version = src.version; # This obviously only works for releases # src = pkgs.npins.mkSource sources.mySource;