fixup tests

This commit is contained in:
David Arnold 2021-05-28 20:26:17 -05:00 committed by "David Arnold"
parent bf231d19fa
commit 39badb2084
No known key found for this signature in database
GPG key ID: 6D6A936E69C59D08
34 changed files with 88 additions and 110 deletions

36
lib/upstreamables.nix Normal file
View file

@ -0,0 +1,36 @@
{ lib, pkgs }:
with lib;
let self = {
importYAML = path: importJSON (pkgs.runCommand "yaml-to-json" { } ''
${pkgs.remarshal}/bin/remarshal -i ${path} -if yaml -of json > $out
'');
toYAML = config: builtins.readFile (pkgs.runCommand "to-yaml" { } ''
${pkgs.remarshal}/bin/remarshal -i ${pkgs.writeText "to-json" (builtins.toJSON config)} -if json -of yaml > $out
'');
toMultiDocumentYaml = name: documents: pkgs.runCommand name { }
(concatMapStringsSep "\necho --- >> $out\n"
(d:
"${pkgs.remarshal}/bin/remarshal -i ${builtins.toFile "doc" (builtins.toJSON d)} -if json -of yaml >> $out"
)
documents);
toBase64 = value:
builtins.readFile
(pkgs.runCommand "value-to-b64" { } "echo -n '${value}' | ${pkgs.coreutils}/bin/base64 -w0 > $out");
exp = base: exp: foldr (value: acc: acc * base) 1 (range 1 exp);
octalToDecimal = value: (foldr
(char: acc: {
i = acc.i + 1;
value = acc.value + (toInt char) * (self.exp 8 acc.i);
})
{ i = 0; value = 0; }
(stringToCharacters value)).value;
};
in self