nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 rustPlatform,
4 fetchFromGitHub,
5 nix-update-script,
6 fetchpatch,
7}:
8
9rustPlatform.buildRustPackage {
10 pname = "formatjson5";
11 version = "0.2.6";
12
13 src = fetchFromGitHub {
14 owner = "google";
15 repo = "json5format";
16 # Not tagged, see Cargo.toml.
17 rev = "056829990bab4ddc78c65a0b45215708c91b8628";
18 hash = "sha256-Lredw/Fez+2U2++ShZcKTFCv8Qpai9YUvqvpGjG5W0o=";
19 };
20
21 patches = [
22 (fetchpatch {
23 url = "https://github.com/google/json5format/commit/32914546e7088b3d9173ae9a2f307effa87917bf.patch";
24 hash = "sha256-kAbRUL/FuhnxkC9Xo4J2bXt9nkMOLeJvgMmOoKnSxKc=";
25 })
26 ];
27
28 cargoHash = "sha256-1CSt9dPVHdOqfQXio7/eXiDLWt+iOe6Qj+VtWblwSDE=";
29
30 cargoBuildFlags = [ "--example formatjson5" ];
31
32 postInstall =
33 let
34 cargoTarget = rustPlatform.cargoInstallHook.targetSubdirectory;
35 in
36 ''
37 install -D target/${cargoTarget}/release/examples/formatjson5 $out/bin/formatjson5
38 '';
39
40 passthru.updateScript = nix-update-script { };
41
42 meta = {
43 description = "JSON5 formatter";
44 homepage = "https://github.com/google/json5format";
45 license = lib.licenses.bsd3;
46 mainProgram = "formatjson5";
47 maintainers = with lib.maintainers; [ katexochen ];
48 };
49}