restructure everything
This commit is contained in:
parent
afb4b62827
commit
fe347d9769
11 changed files with 87 additions and 76 deletions
41
flake.nix
41
flake.nix
|
|
@ -3,9 +3,15 @@
|
|||
|
||||
outputs = { self, ... }:
|
||||
let
|
||||
aliases = {
|
||||
bash = "bash_nixpkgs";
|
||||
fish = "fish_nixpkgs";
|
||||
python = "python_pyproject_nixpkgs_basic";
|
||||
};
|
||||
|
||||
# Get all project directories
|
||||
subdirs = dir:
|
||||
let sub = builtins.readDir dir;
|
||||
let sub = __readDir dir;
|
||||
in builtins.filter
|
||||
(d: sub.${d} == "directory")
|
||||
(builtins.attrNames sub);
|
||||
|
|
@ -16,28 +22,23 @@
|
|||
builtins.foldl' (x: y: x // y) {}
|
||||
(builtins.map func attr);
|
||||
|
||||
templateDirs =
|
||||
builtins.concatMap (lang:
|
||||
builtins.map
|
||||
(pkg: { inherit lang pkg; })
|
||||
(subdirs ./${lang}))
|
||||
(subdirs ./.);
|
||||
flakeSubdirs = dir:
|
||||
builtins.concatMap (sub:
|
||||
if builtins.pathExists /${dir}/${sub}/flake.nix then [ [ sub ] ] else
|
||||
builtins.map (l: [ sub ] ++ l) (flakeSubdirs /${dir}/${sub}))
|
||||
(subdirs dir);
|
||||
in {
|
||||
templates = concatMapAttrs ({ lang, pkg }: {
|
||||
"${lang}-${pkg}" = {
|
||||
description = "Packaging a${if vowelStart lang
|
||||
then "n"
|
||||
else ""} ${lang} executable using ${pkg}";
|
||||
templates = concatMapAttrs (path: {
|
||||
${builtins.concatStringsSep "_" path} = {
|
||||
description = "${builtins.head path} template with ${builtins.concatStringsSep
|
||||
", " (builtins.tail path)}";
|
||||
path = builtins.filterSource
|
||||
(path: type: builtins.baseNameOf path != "flake.lock")
|
||||
./${lang}/${pkg};
|
||||
(builtins.foldl' (dir: sub: /${dir}/${sub}) ./. path);
|
||||
};
|
||||
}) templateDirs // concatMapAttrs (lang: {
|
||||
"${lang}" = self.templates."${lang}-nixpkgs" // {
|
||||
description = "Packaging a${if vowelStart lang
|
||||
then "n"
|
||||
else ""} ${lang} executable";
|
||||
};
|
||||
}) (subdirs ./.);
|
||||
}) (flakeSubdirs ./.) // builtins.mapAttrs (lang: def:
|
||||
self.templates.${def} // {
|
||||
description = "${lang} template";
|
||||
}) aliases;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue