Void CLI #99

Merged
max merged 9 commits from pr-void-cli-paisano into master 2024-07-06 17:11:14 +03:00
2 changed files with 43 additions and 0 deletions
Showing only changes of commit 986df6e838 - Show all commits

42
lib/catalog.nix Normal file
View file

@ -0,0 +1,42 @@
{ config, lib, withSystem, ... }:
{
lib = {
catalog = {
init = lib.genAttrs config.systems (system: withSystem system ({ config, ... }: lib.mapAttrsToList (name: cell: {
cell = name;
cellBlocks = lib.mapAttrsToList (name: block: {
blockType = "catalogBlock";
cellBlock = name;
targets = lib.mapAttrsToList (name: target: {
inherit name;
inherit (target) description;
actions = lib.mapAttrsToList (name: action: {
inherit name;
inherit (action) description;
}) target.actions;
}) block;
}) cell;
}) config.catalog));
actions = lib.genAttrs config.systems (system: withSystem system ({ config, pkgs, ... }:
lib.mapAttrs (name: cell:
lib.mapAttrs (name: block:
lib.mapAttrs (name: target:
lib.mapAttrs (name: action:
let
binPath = lib.makeBinPath action.packages;
in pkgs.writeShellScript name ''
# Void CLI Action
# ---
${lib.optionalString (action.packages != []) ''export PATH="${binPath}:$PATH"''}
# ---
${action.command}
'') target.actions
) block
) cell
)
config.catalog));
};
};
}

View file

@ -7,6 +7,7 @@
./meta.nix
./nginx.nix
./identity.nix
./catalog.nix
];
options.lib = lib.mkOption {