Commit e23ad3bd authored by phaer's avatar phaer Committed by phaer
Browse files

pkgs-lib/formats: switch toml generator from yj to go-toml (jsontoml)

Fixes NixOS/nixpkgs#511970, sclevine/yj#52.

Replace yj with go-toml's jsontoml for JSON-to-TOML conversion.
Update tomlAtoms expected output for go-toml's literal-string style.
parent d5551849
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -461,16 +461,18 @@ optionalAttrs allowAliases aliases
      generate =
        name: value:
        pkgs.callPackage (
          { runCommand, yj }:
          { runCommand, go-toml }:
          runCommand name
            {
              nativeBuildInputs = [ yj ];
              nativeBuildInputs = [ go-toml ];
              value = builtins.toJSON value;
              passAsFile = [ "value" ];
              preferLocalBuild = true;
            }
            # -use-json-number: preserve JSON ints as TOML ints
            # (Go's json.Decoder defaults to float64 for all numbers)
            ''
              yj -jt < "$valuePath" > "$out"
              jsontoml -use-json-number < "$valuePath" > "$out"
            ''
        ) { };

+3 −3
Original line number Diff line number Diff line
@@ -695,16 +695,16 @@ runBuildTests {
      float = 3.141
      int = 10
      list = [1, 2]
      str = "foo"
      str = 'foo'
      true = true

      [attrs]
      foo = "foo"
      foo = 'foo'

      [level1]
      [level1.level2]
      [level1.level2.level3]
      level4 = "deep"
      level4 = 'deep'
    '';
  };