templates: handle non-flake templates

This commit is contained in:
Infinidoge 2024-09-04 01:51:46 -04:00
parent 6047b5361f
commit 5d1990096e
Signed by: Infinidoge
SSH key fingerprint: SHA256:oAMyvotlNFraMmZmr+p6AxnNfW/GioTs1pOn3V4tQ7A

View file

@ -3,10 +3,11 @@ let
mkTemplate = name: mkTemplate = name:
let let
path = ./. + "/${name}"; path = ./. + "/${name}";
flake = import (path + "/flake.nix"); flakePath = path + "/flake.nix";
meta = if builtins.pathExists flakePath then import flakePath else { };
in in
{ inherit path; } { inherit path; }
// lib.optionalAttrs (flake ? description) { inherit (flake) description; }; // lib.optionalAttrs (meta ? description) { inherit (meta) description; };
templates = lib.attrNames (lib.filterAttrs (_: type: type == "directory") (builtins.readDir ./.)); templates = lib.attrNames (lib.filterAttrs (_: type: type == "directory") (builtins.readDir ./.));
in in