dotfiles/nix/repo/lib/default.nix

31 lines
975 B
Nix
Raw Normal View History

std-passthru @ {
2023-06-18 09:51:33 +00:00
inputs,
cell,
}: let
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
'');
exec_tests = testUnit: let
testNames = builtins.attrNames testUnit;
evaluateTest = testName: assert testUnit."${testName}" == true; testName;
in
builtins.concatStringsSep ", " (builtins.foldl' (acc: testName: acc ++ [(evaluateTest testName)]) [] testNames);
tests = import ./tests.nix std-passthru;
2023-06-18 09:51:33 +00:00
in {
fromYAML = yamlContent: builtins.fromJSON (builtins.readFile (yamlToJsonDrv inputs.nixpkgs yamlContent "fromYaml.json"));
ty = import ./ty.nix std-passthru;
deprecate = import ./mk-deprecate.nix std-passthru;
inherit tests;
exec-tests = exec_tests tests;
}