44 lines
1.4 KiB
Nix
44 lines
1.4 KiB
Nix
{
|
|
description = "Templates of the Sieve of Eratosthenes implemented in various languages";
|
|
|
|
outputs = { self, ... }:
|
|
let
|
|
# Get all project directories
|
|
subdirs = dir:
|
|
let sub = builtins.readDir dir;
|
|
in builtins.filter
|
|
(d: sub.${d} == "directory")
|
|
(builtins.attrNames sub);
|
|
|
|
vowelStart = str: builtins.elem (builtins.substring 0 1 str) [ "a" "e" "i" "o" "u" ];
|
|
|
|
concatMapAttrs = func: attr:
|
|
builtins.foldl' (x: y: x // y) {}
|
|
(builtins.map func attr);
|
|
|
|
templateDirs =
|
|
builtins.concatMap (lang:
|
|
builtins.map
|
|
(pkg: { inherit lang pkg; })
|
|
(subdirs ./${lang}))
|
|
(subdirs ./.);
|
|
in {
|
|
templates = concatMapAttrs ({ lang, pkg }: {
|
|
"${lang}-${pkg}" = {
|
|
description = "Packaging a${if vowelStart lang
|
|
then "n"
|
|
else ""} ${lang} executable using ${pkg}";
|
|
path = builtins.filterSource
|
|
(path: type: builtins.baseNameOf path != "flake.lock")
|
|
./${lang}/${pkg};
|
|
};
|
|
}) templateDirs // concatMapAttrs (lang: {
|
|
"${lang}" = self.templates."${lang}-nixpkgs" // {
|
|
description = "Packaging a${if vowelStart lang
|
|
then "n"
|
|
else ""} ${lang} executable";
|
|
};
|
|
}) (subdirs ./.);
|
|
};
|
|
}
|