This commit is contained in:
GTrunSec 2022-04-02 12:40:35 -07:00
parent a0ce293db8
commit 60592d3096
No known key found for this signature in database
GPG key ID: 2368FAFA4ABDD2A0
55 changed files with 23668 additions and 30925 deletions

View file

@ -1,36 +1,45 @@
{ lib, pkgs }:
{
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
'');
with lib;
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
'');
let self = {
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);
importYAML = path: importJSON (pkgs.runCommand "yaml-to-json" { } ''
${pkgs.remarshal}/bin/remarshal -i ${path} -if yaml -of json > $out
'');
toBase64 = value:
builtins.readFile
(pkgs.runCommand "value-to-b64" {} "echo -n '${value}' | ${pkgs.coreutils}/bin/base64 -w0 > $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
'');
exp = base: exp: foldr (value: acc: acc * base) 1 (range 1 exp);
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
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