mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-23 14:31:55 +03:00
42838c5909
- name example more consistently, eg. `{language}-packaging-{feature}` or `{language}-local-development-{feature}` - move some examples to the modules integration tests directory instead as their purpose was mainly testing and they weren't good example - module owned checks: import via flake if available
74 lines
1.7 KiB
Nix
74 lines
1.7 KiB
Nix
{
|
|
self,
|
|
lib,
|
|
inputs,
|
|
...
|
|
}: {
|
|
perSystem = {
|
|
self',
|
|
pkgs,
|
|
system,
|
|
...
|
|
}: let
|
|
dream2nixFlake = import ../../. {};
|
|
|
|
importFlake = flakeFile: let
|
|
self' = (import flakeFile).outputs {
|
|
dream2nix = dream2nixFlake;
|
|
nixpkgs = inputs.nixpkgs;
|
|
self = self';
|
|
};
|
|
in
|
|
self';
|
|
|
|
modules = self.modules.dream2nix;
|
|
|
|
modulesWithTests =
|
|
lib.filterAttrs
|
|
(_: module: lib.pathExists (module + /tests/packages))
|
|
modules;
|
|
|
|
getPackagePaths = moduleName: modulePath:
|
|
lib.concatMapAttrs
|
|
(packageDir: _: {
|
|
"module-${moduleName}-${packageDir}" = "${modulePath}/tests/packages/${packageDir}";
|
|
})
|
|
(builtins.readDir (modulePath + /tests/packages));
|
|
|
|
makePackage = path:
|
|
if lib.pathExists (path + "/flake.nix")
|
|
then makePackageFromFlake path
|
|
else makePackageFromDefaultNix path;
|
|
|
|
makePackageFromFlake = flakePath:
|
|
(importFlake (flakePath + "/flake.nix")).packages.${system}.default or {};
|
|
|
|
makePackageFromDefaultNix = testModulePath: let
|
|
evaled = lib.evalModules {
|
|
specialArgs = {
|
|
dream2nix = dream2nixFlake;
|
|
|
|
packageSets.nixpkgs = pkgs;
|
|
};
|
|
modules = [
|
|
testModulePath
|
|
{
|
|
paths.projectRoot = testModulePath;
|
|
paths.package = testModulePath;
|
|
}
|
|
];
|
|
};
|
|
in
|
|
evaled.config.public;
|
|
|
|
packagesToBuild =
|
|
lib.concatMapAttrs getPackagePaths modulesWithTests;
|
|
|
|
packagesBuilt = lib.mapAttrs (_: makePackage) packagesToBuild;
|
|
|
|
packagesFiltered = lib.filterAttrs (_: pkg: pkg != {}) packagesBuilt;
|
|
in {
|
|
checks = self'.packages // packagesFiltered;
|
|
};
|
|
}
|