From 06bd0d96cee1a99c1df4edbd2a0943610edc42a0 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sat, 6 Jan 2024 02:08:03 +0100 Subject: [PATCH 1/3] templates/simple: remove useless `self` from extraSpecialArgs --- templates/simple/config/default.nix | 2 +- templates/simple/flake.nix | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) 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 { From 5b7952f2b4cc1ff105a95496df7667fbef87234e Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sat, 6 Jan 2024 02:08:43 +0100 Subject: [PATCH 2/3] flake/templates: propagate the template's checks to the main flake's --- flake-modules/templates.nix | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) 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; + }; } From 572d7bfcfa845b43cc51bcbce8323662c76951e9 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sat, 6 Jan 2024 02:09:20 +0100 Subject: [PATCH 3/3] ci/check: remove useless check of the template flake --- .github/workflows/check.yml | 1 - 1 file changed, 1 deletion(-) 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