2024-11-13 15:24:41 +01:00
|
|
|
{ config, lib, ... }:
|
|
|
|
let
|
|
|
|
inherit (lib)
|
|
|
|
mkOption
|
|
|
|
types
|
|
|
|
;
|
|
|
|
cfg = config;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.assets = mkOption {
|
|
|
|
description = ''
|
|
|
|
Collection of assets, i.e. static files that can be linked to from within documents
|
|
|
|
'';
|
|
|
|
type = with types; attrsOf (submodule ({ config, ... }: {
|
|
|
|
imports = [ cfg.content-types.document ];
|
|
|
|
options.path = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
};
|
2024-11-13 15:24:41 +01:00
|
|
|
config.outputs."" = if lib.isStorePath config.path then config.path else "${config.path}";
|
2024-11-13 15:24:41 +01:00
|
|
|
}));
|
|
|
|
default = { };
|
|
|
|
};
|
|
|
|
|
|
|
|
config.files = with lib;
|
|
|
|
let
|
|
|
|
flatten = attrs: mapAttrsToList
|
|
|
|
(name: value:
|
|
|
|
# HACK: we somehow have to distinguish a module value from regular attributes.
|
|
|
|
# arbitrary choice: the outputs attribute
|
|
|
|
if value ? outputs then value else mapAttrsToList value)
|
|
|
|
attrs;
|
|
|
|
in
|
|
|
|
cfg.templates.files (flatten cfg.assets);
|
|
|
|
}
|