Excise use of importJSON

Putting information in external JSON files is IMHO not an improvement
over the idiomatic style of Nix expressions. The use of JSON doesn't
add anything over Nix expressions (in fact it removes expressive
power). And scattering package info over lots of little files makes
packages less readable over having the info in one file.
This commit is contained in:
Eelco Dolstra 2017-01-30 11:18:56 +01:00
parent 2dc87881b0
commit c20cc6d0b3
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
10 changed files with 30 additions and 53 deletions

View file

@ -102,25 +102,7 @@ rec {
min = x: y: if x < y then x else y;
max = x: y: if x > y then x else y;
/* Reads a JSON file. It is useful to import pure data into other nix
expressions.
Example:
mkDerivation {
src = fetchgit (importJSON ./repo.json)
#...
}
where repo.json contains:
{
"url": "git://some-domain/some/repo",
"rev": "265de7283488964f44f0257a8b4a055ad8af984d",
"sha256": "0sb3h3067pzf3a7mlxn1hikpcjrsvycjcnj9hl9b1c3ykcgvps7h"
}
*/
/* Reads a JSON file. */
importJSON = path:
builtins.fromJSON (builtins.readFile path);

View file

@ -10,7 +10,13 @@ stdenv.mkDerivation rec {
libpthreadstubs libXau libXdmcp libXrandr libXext libXinerama libXxf86vm
libXcursor libXfixes
];
src = fetchgit (stdenv.lib.importJSON ./src.json);
src = fetchgit {
url = https://github.com/mkeeter/ao;
rev = "69fadb81543cc9031e4a7ec2036c7f2ab505a620";
sha256 = "1717k72vr0i5j7bvxmd6q16fpvkljnqfa1hr3i4yq8cjdsj69my7";
};
cmakeFlags = "-G Ninja";
buildPhase = "ninja";
installPhase = ''

View file

@ -1,5 +0,0 @@
{
"url": "https://github.com/mkeeter/ao",
"rev": "69fadb81543cc9031e4a7ec2036c7f2ab505a620",
"sha256": "1717k72vr0i5j7bvxmd6q16fpvkljnqfa1hr3i4yq8cjdsj69my7"
}

View file

@ -18,11 +18,14 @@ let
python = python2;
buildType = "release";
inherit (importJSON ./upstream-info.json) version extpackRev extpack main;
extpack = "3982657fd4853bcbc79b9162e618545a479b65aca08e9ced43a904aeeba3ffa5";
extpackRev = 112026;
main = "98073b1b2adee4e6553df73cb5bb6ea8ed7c3a41a475757716fd9400393bea40";
version = "5.1.10";
# See https://github.com/NixOS/nixpkgs/issues/672 for details
extensionPack = requireFile rec {
name = "Oracle_VM_VirtualBox_Extension_Pack-${version}-${extpackRev}.vbox-extpack";
name = "Oracle_VM_VirtualBox_Extension_Pack-${version}-${toString extpackRev}.vbox-extpack";
sha256 = extpack;
message = ''
In order to use the extension pack, you need to comply with the VirtualBox Personal Use

View file

@ -12,7 +12,7 @@ stdenv.mkDerivation {
src = fetchurl {
url = "http://download.virtualbox.org/virtualbox/${version}/VBoxGuestAdditions_${version}.iso";
sha256 = (lib.importJSON ../upstream-info.json).guest;
sha256 = "29fa0af66a3dd273b0c383c4adee31a52061d52f57d176b67f444698300b8c41";
};
KERN_DIR = "${kernel.dev}/lib/modules/*/build";

View file

@ -1,8 +0,0 @@
{
"__NOTE": "Generated using update.py from the same directory.",
"extpack": "3982657fd4853bcbc79b9162e618545a479b65aca08e9ced43a904aeeba3ffa5",
"extpackRev": "112026",
"guest": "29fa0af66a3dd273b0c383c4adee31a52061d52f57d176b67f444698300b8c41",
"main": "98073b1b2adee4e6553df73cb5bb6ea8ed7c3a41a475757716fd9400393bea40",
"version": "5.1.10"
}

View file

@ -10,7 +10,14 @@ stdenv.mkDerivation rec{
libjpeg zeromq3 ncurses openssl libpng readline pkgconfig
zlib libX11 which
];
src = fetchgit (stdenv.lib.importJSON ./src.json);
src = fetchgit {
url = "https://github.com/torch/distro";
rev = "8b6a834f8c8755f6f5f84ef9d8da9cfc79c5ce1f";
sha256 = "120hnz82d7izinsmv5smyqww71dhpix23pm43s522dfcglpql8xy";
fetchSubmodules = true;
};
buildPhase = ''
cd ..
export PREFIX=$out

View file

@ -1,6 +0,0 @@
{
"url": "https://github.com/torch/distro",
"rev": "8b6a834f8c8755f6f5f84ef9d8da9cfc79c5ce1f",
"sha256": "120hnz82d7izinsmv5smyqww71dhpix23pm43s522dfcglpql8xy",
"fetchSubmodules": true
}

View file

@ -1,12 +1,15 @@
{ stdenv, fetchurl, kernel, writeScript, coreutils, gnugrep, jq, curl
}:
let
data = stdenv.lib.importJSON ./update.json;
in stdenv.mkDerivation rec {
name = "tp_smapi-${data.version}-${kernel.version}";
stdenv.mkDerivation rec {
name = "tp_smapi-${version}-${kernel.version}";
src = fetchurl { inherit (data) url sha256; };
version = "0.42";
src = fetchurl {
url = "https://github.com/evgeni/tp_smapi/archive/tp-smapi/${version}.tar.gz";
sha256 = "cd28bf6ee21b2c27b88d947cb0bfcb19648c7daa5d350115403dbcad05849381";
};
hardeningDisable = [ "pic" ];

View file

@ -1,5 +0,0 @@
{
"version": "0.42",
"url": "https://github.com/evgeni/tp_smapi/archive/tp-smapi/0.42.tar.gz",
"sha256": "cd28bf6ee21b2c27b88d947cb0bfcb19648c7daa5d350115403dbcad05849381"
}