dotfiles/nix/cells/repo/lib/default.nix

21 lines
540 B
Nix
Raw Normal View History

2023-06-18 09:51:33 +00:00
{
inputs,
cell,
}: let
namespace = "repo"; # ignore: unused
yamlToJsonDrv = pkgs: yamlContent: outputPath: (pkgs.runCommand
outputPath
2023-06-18 09:51:33 +00:00
{
inherit yamlContent;
nativeBuildInputs = [pkgs.yq];
}
# run yq which outputs '.' (no filter) on file at yamlPath
# note that $out is passed onto the bash/sh script for execution
''
echo "$yamlContent" | yq >$out
'');
2023-06-18 09:51:33 +00:00
in {
fromYAML = yamlContent: builtins.fromJSON (builtins.readFile (yamlToJsonDrv inputs.nixpkgs yamlContent "fromYaml.json"));
}