2023-01-30 22:21:14 -05:00
|
|
|
{
|
2024-07-28 06:01:20 -04:00
|
|
|
description = "Templates of the Sieve of Eratosthenes implemented in various languages";
|
2023-01-30 22:21:14 -05:00
|
|
|
|
2024-07-28 06:01:20 -04:00
|
|
|
outputs = { self, ... }:
|
|
|
|
let
|
|
|
|
# Get all project directories
|
|
|
|
subdirs = dir:
|
|
|
|
let sub = builtins.readDir dir;
|
|
|
|
in builtins.filter
|
|
|
|
(d: sub.${d} == "directory")
|
|
|
|
(builtins.attrNames sub);
|
2023-01-30 22:21:14 -05:00
|
|
|
|
2024-07-28 06:01:20 -04:00
|
|
|
vowelStart = str: builtins.elem (builtins.substring 0 1 str) [ "a" "e" "i" "o" "u" ];
|
2023-01-30 22:21:14 -05:00
|
|
|
|
2024-07-28 06:01:20 -04:00
|
|
|
concatMapAttrs = func: attr:
|
|
|
|
builtins.foldl' (x: y: x // y) {}
|
|
|
|
(builtins.map func attr);
|
2023-02-07 14:24:32 -05:00
|
|
|
|
2024-07-28 06:01:20 -04:00
|
|
|
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 ./.);
|
|
|
|
};
|
2023-01-30 22:21:14 -05:00
|
|
|
}
|