2022-10-28 21:29:30 +03:00
|
|
|
{ nixpkgs, idris, flake-utils, system, stdenv, runCommand, lib }:
|
2021-03-15 17:21:50 +03:00
|
|
|
let
|
|
|
|
withTests = tests: drv:
|
2022-10-28 21:29:30 +03:00
|
|
|
let
|
|
|
|
testDrvs = lib.mapAttrs (name: testScript:
|
|
|
|
runCommand "${drv.name}-test-${name}" { } ''
|
|
|
|
${testScript}
|
|
|
|
touch "$out"
|
|
|
|
'') tests;
|
|
|
|
in testDrvs;
|
|
|
|
createTemplate = flake: inputs: type:
|
|
|
|
let
|
|
|
|
self = import flake;
|
|
|
|
template =
|
|
|
|
self.outputs ({ inherit self nixpkgs idris flake-utils; } // inputs);
|
|
|
|
templateBuild = template.packages.${system}.${type};
|
2021-03-15 17:21:50 +03:00
|
|
|
in templateBuild;
|
|
|
|
|
2022-10-28 21:29:30 +03:00
|
|
|
templateBuildDefault = createTemplate ./templates/pkg/flake.nix { } "build";
|
|
|
|
templateBuildDefaultLibrary =
|
|
|
|
createTemplate ./templates/pkg/flake.nix { } "installLibrary";
|
|
|
|
templateBuildWithDeps = createTemplate ./templates/pkgWithDeps/flake.nix {
|
|
|
|
pkg = templateBuildDefaultLibrary;
|
|
|
|
} "build";
|
2021-03-15 17:21:50 +03:00
|
|
|
|
|
|
|
testsTemplate = {
|
|
|
|
checkFoo = ''
|
|
|
|
${templateBuildDefault}/bin/runMyPkg \
|
|
|
|
| grep "Foo"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
testsTemplateWithDeps = {
|
|
|
|
checkBar = ''
|
|
|
|
${templateBuildWithDeps}/bin/runMyPkg2 \
|
|
|
|
| grep "Bar"
|
|
|
|
'';
|
|
|
|
};
|
2022-10-28 21:29:30 +03:00
|
|
|
in withTests testsTemplate templateBuildDefault
|
|
|
|
// withTests testsTemplateWithDeps templateBuildWithDeps // {
|
|
|
|
idris2Tests =
|
|
|
|
idris.defaultPackage.${system}.overrideAttrs (a: { doCheck = true; });
|
|
|
|
}
|