Loading pkgs/by-name/js/json2cdn/package.nix +5 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ gradle_8, jre_headless, makeBinaryWrapper, tests, }: stdenv.mkDerivation (finalAttrs: { pname = "json2cdn"; Loading Loading @@ -42,6 +43,10 @@ stdenv.mkDerivation (finalAttrs: { runHook postInstall ''; passthru = { tests.formats-cdn = tests.pkgs-lib.formats.passthru.entries.pass-cdnAtoms; }; meta = { description = "Converts a JSON file to dzikoysk's CDN format"; homepage = "https://github.com/uku3lig/json2cdn"; Loading pkgs/pkgs-lib/formats.nix +33 −0 Original line number Diff line number Diff line Loading @@ -310,6 +310,39 @@ rec { }; /* dzikoysk's CDN format, see https://github.com/dzikoysk/cdn The result is almost identical to YAML when there are no nested properties, but differs enough in the other case to warrant a separate format. (see https://github.com/dzikoysk/cdn#supported-formats) Currently used by Panda, Reposilite, and FunnyGuilds (as per the repo's readme). */ cdn = {}: json {} // { type = let valueType = nullOr (oneOf [ bool int float str path (attrsOf valueType) (listOf valueType) ]) // { description = "CDN value"; }; in valueType; generate = name: value: pkgs.callPackage ({ runCommand, json2cdn }: runCommand name { nativeBuildInputs = [ json2cdn ]; value = builtins.toJSON value; passAsFile = [ "value" ]; preferLocalBuild = true; } '' json2cdn "$valuePath" > $out '') {}; }; /* For configurations of Elixir project, like config.exs or runtime.exs Most Elixir project are configured using the [Config] Elixir DSL Loading pkgs/pkgs-lib/tests/formats.nix +34 −0 Original line number Diff line number Diff line Loading @@ -533,6 +533,40 @@ in runBuildTests { ''; }; cdnAtoms = shouldPass { format = formats.cdn { }; input = { null = null; false = false; true = true; int = 10; float = 3.141; str = "foo"; attrs.foo = null; list = [ 1 null ]; path = ./formats.nix; }; expected = '' attrs { "foo": null } "false": false "float": 3.141 "int": 10 list [ 1, null ] "null": null "path": "${./formats.nix}" "str": "foo" "true": true ''; }; # This test is responsible for # 1. testing type coercions # 2. providing a more readable example test Loading Loading
pkgs/by-name/js/json2cdn/package.nix +5 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ gradle_8, jre_headless, makeBinaryWrapper, tests, }: stdenv.mkDerivation (finalAttrs: { pname = "json2cdn"; Loading Loading @@ -42,6 +43,10 @@ stdenv.mkDerivation (finalAttrs: { runHook postInstall ''; passthru = { tests.formats-cdn = tests.pkgs-lib.formats.passthru.entries.pass-cdnAtoms; }; meta = { description = "Converts a JSON file to dzikoysk's CDN format"; homepage = "https://github.com/uku3lig/json2cdn"; Loading
pkgs/pkgs-lib/formats.nix +33 −0 Original line number Diff line number Diff line Loading @@ -310,6 +310,39 @@ rec { }; /* dzikoysk's CDN format, see https://github.com/dzikoysk/cdn The result is almost identical to YAML when there are no nested properties, but differs enough in the other case to warrant a separate format. (see https://github.com/dzikoysk/cdn#supported-formats) Currently used by Panda, Reposilite, and FunnyGuilds (as per the repo's readme). */ cdn = {}: json {} // { type = let valueType = nullOr (oneOf [ bool int float str path (attrsOf valueType) (listOf valueType) ]) // { description = "CDN value"; }; in valueType; generate = name: value: pkgs.callPackage ({ runCommand, json2cdn }: runCommand name { nativeBuildInputs = [ json2cdn ]; value = builtins.toJSON value; passAsFile = [ "value" ]; preferLocalBuild = true; } '' json2cdn "$valuePath" > $out '') {}; }; /* For configurations of Elixir project, like config.exs or runtime.exs Most Elixir project are configured using the [Config] Elixir DSL Loading
pkgs/pkgs-lib/tests/formats.nix +34 −0 Original line number Diff line number Diff line Loading @@ -533,6 +533,40 @@ in runBuildTests { ''; }; cdnAtoms = shouldPass { format = formats.cdn { }; input = { null = null; false = false; true = true; int = 10; float = 3.141; str = "foo"; attrs.foo = null; list = [ 1 null ]; path = ./formats.nix; }; expected = '' attrs { "foo": null } "false": false "float": 3.141 "int": 10 list [ 1, null ] "null": null "path": "${./formats.nix}" "str": "foo" "true": true ''; }; # This test is responsible for # 1. testing type coercions # 2. providing a more readable example test Loading