nix-community.nixvim/flake/dev/template-tests.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.4 KiB
Nix
Raw Normal View History

{ self, inputs, ... }:
{
# The following adds the template flake's checks to the main (current) flake's checks.
# It ensures that the template's own checks are successful.
perSystem =
{
pkgs,
system,
lib,
...
}:
{
checks =
let
# Approximates https://github.com/NixOS/nix/blob/96e550ef/src/libexpr/call-flake.nix#L67-L85
callFlake =
flake@{
inputs,
outputs,
sourceInfo ? { },
}:
let
outputs = flake.outputs (inputs // { self = result; });
result =
outputs
// sourceInfo
// {
inherit inputs outputs sourceInfo;
_type = "flake";
};
in
result;
flakes = lib.mapAttrs (
name: template:
callFlake {
# Use inputs from our flake
inputs = {
inherit (inputs) flake-parts nixpkgs;
nixvim = self;
};
# Use outputs from the template flake
inherit (import "${template.path}/flake.nix") outputs;
}
) self.templates;
in
lib.concatMapAttrs (name: flake: {
"template-${name}" = pkgs.linkFarm name flake.checks.${system};
}) flakes;
};
}