nix-community.nixvim/flake/dev/template-tests.nix
Matt Sturgeon 6d10fc0c87
flake: partition dev dependencies
This removes the need for end-users to manually set
`nixvim.inputs.devshell.follows = ""` (etc)

We offload evaluation of some of our flake modules into a `dev`
partition submodule.
- When its not needed, this submodule is not evaluated.
- When it is needed, it fetches extra inputs from `flake/dev/flake.nix`
  as part of evaluating the submodule.

See https://flake.parts/options/flake-parts-partitions.html
2025-02-23 17:23:57 +00:00

51 lines
1.4 KiB
Nix

{ 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;
};
}