mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-19 01:01:59 +03:00
8746f1671b
* Refactor buildIdris slightly and support installing libraries with source. Add the Idris2 API package as an output of the flake. * update templates and simplify construction of a search path. * use newer method of specifying default package * swap out trace function for warn function. fix warnings in template generation
43 lines
1.3 KiB
Nix
43 lines
1.3 KiB
Nix
{ nixpkgs, idris, flake-utils, system, stdenv, runCommand, lib }:
|
|
let
|
|
withTests = tests: drv:
|
|
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};
|
|
in templateBuild;
|
|
|
|
templateBuildDefault = createTemplate ./templates/pkg/flake.nix { } "executable";
|
|
templateBuildDefaultLibrary =
|
|
createTemplate ./templates/pkg/flake.nix { } "library" { };
|
|
templateBuildWithDeps = createTemplate ./templates/pkgWithDeps/flake.nix {
|
|
pkg = templateBuildDefaultLibrary;
|
|
} "executable";
|
|
|
|
testsTemplate = {
|
|
checkFoo = ''
|
|
${templateBuildDefault}/bin/runMyPkg \
|
|
| grep "Foo"
|
|
'';
|
|
};
|
|
testsTemplateWithDeps = {
|
|
checkBar = ''
|
|
${templateBuildWithDeps}/bin/runMyPkg2 \
|
|
| grep "Bar"
|
|
'';
|
|
};
|
|
in withTests testsTemplate templateBuildDefault
|
|
// withTests testsTemplateWithDeps templateBuildWithDeps // {
|
|
idris2Tests =
|
|
idris.packages.${system}.default.overrideAttrs (a: { doCheck = true; });
|
|
}
|