diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index f86d3181a8..46faecd535 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -20,4 +20,3 @@ jobs: name: nix-community authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - run: nix flake check --all-systems --builders "" - - run: nix flake check --all-systems --builders "" ./templates/_wrapper/simple --no-write-lock-file diff --git a/flake-modules/templates.nix b/flake-modules/templates.nix index 07e79d4773..bb23b69a52 100644 --- a/flake-modules/templates.nix +++ b/flake-modules/templates.nix @@ -1,8 +1,60 @@ { + self, + inputs, + ... +}: { flake.templates = { default = { path = ../templates/simple; description = "A simple nix flake template for getting started with nixvim"; }; }; + + # 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/7cd08ae379746749506f2e33c3baeb49b58299b8/src/libexpr/flake/call-flake.nix#L46 + # s/flake.outputs/args.outputs/ + callFlake = args @ { + inputs, + outputs, + sourceInfo, + }: let + outputs = args.outputs (inputs // {self = result;}); + result = + outputs + // sourceInfo + // { + inherit inputs outputs sourceInfo; + _type = "flake"; + }; + in + result; + + templateFlakeOuputs = callFlake { + inputs = { + inherit (inputs) flake-parts nixpkgs; + nixvim = self; + }; + # Import and read the `outputs` field of the template flake. + inherit (import ../templates/simple/flake.nix) outputs; + sourceInfo = {}; + }; + + templateChecks = templateFlakeOuputs.checks.${system}; + in + lib.concatMapAttrs + ( + checkName: check: { + "template-${checkName}" = check; + } + ) + templateChecks; + }; } diff --git a/templates/simple/config/default.nix b/templates/simple/config/default.nix index 9960707993..f9a64549b9 100644 --- a/templates/simple/config/default.nix +++ b/templates/simple/config/default.nix @@ -1,4 +1,4 @@ -{self, ...}: { +{ # Import all your configuration modules here imports = [ ./bufferline.nix diff --git a/templates/simple/flake.nix b/templates/simple/flake.nix index b705dbe75f..2045407da4 100644 --- a/templates/simple/flake.nix +++ b/templates/simple/flake.nix @@ -8,7 +8,6 @@ }; outputs = { - self, nixvim, flake-parts, ... @@ -35,7 +34,7 @@ module = config; # You can use `extraSpecialArgs` to pass additional arguments to your module files extraSpecialArgs = { - inherit self; + # inherit (inputs) foo; }; }; in {