From 16647cc5efa9f41a73108e168207628691a2151b Mon Sep 17 00:00:00 2001 From: Jaka Hudoklin Date: Fri, 1 Dec 2017 12:40:28 +0100 Subject: [PATCH] feat(lib): add toYAML method --- default.nix | 2 +- lib.nix | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/default.nix b/default.nix index 9b6967a..96a005d 100644 --- a/default.nix +++ b/default.nix @@ -14,7 +14,7 @@ let args = { inherit pkgs; name = "default"; - k8s = { inherit loadJSON loadYAML toBase64 octalToDecimal mkValueOrSecretOption; }; + k8s = { inherit loadJSON loadYAML toYAML toBase64 octalToDecimal mkValueOrSecretOption; }; }; }; diff --git a/lib.nix b/lib.nix index 1661f82..381621a 100644 --- a/lib.nix +++ b/lib.nix @@ -26,6 +26,12 @@ rec { loadYAML = path: loadJSON (pkgs.runCommand "yaml-to-json" { } "${pkgs.remarshal}/bin/remarshal -i ${path} -if yaml -of json > $out"); + toYAML = config: builtins.readFile (pkgs.runCommand "to-yaml" { + buildInputs = [pkgs.remarshal]; + } '' + remarshal -i ${pkgs.writeText "to-json" (builtins.toJSON config)} -if json -of yaml > $out + ''); + toBase64 = value: builtins.readFile (pkgs.runCommand "value-to-b64" {} "echo '${value}' | ${pkgs.coreutils}/bin/base64 -w0 > $out");