forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
formats.hocon: add backwards compatibility
- Loading branch information
Showing
5 changed files
with
170 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
pkgs/pkgs-lib/formats/hocon/test/backwards-compatibility/default.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ lib, formats, stdenvNoCC, writeText, ... }: | ||
let | ||
hocon = formats.hocon { }; | ||
|
||
expression = { | ||
substitution = { __hocon_envvar = "PATH"; }; | ||
literal = { | ||
__hocon_unquoted_string = '' | ||
[ | ||
1, | ||
"a", | ||
]''; | ||
}; | ||
|
||
nested = { | ||
substitution = { __hocon_envvar = "PATH"; }; | ||
literal = { | ||
__hocon_unquoted_string = '' | ||
[ | ||
1, | ||
"a", | ||
]''; | ||
}; | ||
}; | ||
|
||
nested_in_array = [ | ||
{ __hocon_envvar = "PATH"; } | ||
{ | ||
__hocon_unquoted_string = '' | ||
[ | ||
1, | ||
"a", | ||
]''; | ||
} | ||
]; | ||
}; | ||
|
||
hocon-test-conf = hocon.generate "hocon-test.conf" expression; | ||
in | ||
stdenvNoCC.mkDerivation { | ||
name = "pkgs.formats.hocon-test-backwards-compatibility"; | ||
|
||
dontUnpack = true; | ||
dontBuild = true; | ||
|
||
doCheck = true; | ||
checkPhase = '' | ||
runHook preCheck | ||
diff -U3 ${./expected.txt} ${hocon-test-conf} | ||
runHook postCheck | ||
''; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
mkdir $out | ||
cp ${./expected.txt} $out/expected.txt | ||
cp ${hocon-test-conf} $out/hocon-test.conf | ||
cp ${hocon-test-conf.passthru.json} $out/hocon-test.json | ||
runHook postInstall | ||
''; | ||
} |
22 changes: 22 additions & 0 deletions
22
pkgs/pkgs-lib/formats/hocon/test/backwards-compatibility/expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"literal" = [ | ||
1, | ||
"a", | ||
] | ||
"nested" = { | ||
"literal" = [ | ||
1, | ||
"a", | ||
] | ||
"substitution" = ${?PATH} | ||
} | ||
"nested_in_array" = [ | ||
${?PATH}, | ||
[ | ||
1, | ||
"a", | ||
] | ||
] | ||
"substitution" = ${?PATH} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,15 @@ | ||
{ pkgs, ... }: | ||
{ | ||
comprehensive = pkgs.callPackage ./comprehensive { }; | ||
backwards-compatibility = | ||
let | ||
pkgsNoWarn = pkgs.extend (final: prev: { | ||
lib = prev.lib.extend (libFinal: libPrev: { | ||
warn = msg: v: v; | ||
trivial = libPrev.trivial // { | ||
warn = msg: v: v; | ||
}; | ||
}); | ||
}); | ||
in pkgsNoWarn.callPackage ./backwards-compatibility { }; | ||
} |