fediversity.eu/structure/default.nix

57 lines
1.3 KiB
Nix
Raw Normal View History

2024-10-11 17:11:48 +02:00
{ config, options, lib, pkgs, ... }:
let
inherit (lib)
mkOption
types
;
cfg = config;
in
{
2024-10-12 11:38:03 +02:00
imports = [ ./content-types.nix ];
2024-10-11 21:38:57 +02:00
2024-10-11 17:11:48 +02:00
options.pages = mkOption {
description = ''
Collection of pages on the site
'';
2024-10-12 11:38:03 +02:00
type = with types; attrsOf (submodule config.content-types.page);
2024-10-11 21:38:57 +02:00
};
2024-10-11 17:11:48 +02:00
2024-10-11 21:38:57 +02:00
options.collections = mkOption
{
description = ''
Named collections of unnamed pages
2024-10-13 11:36:54 +02:00
Define the content type of a new collection `example` to be `article`:
```nix
config.collections.example.type = config.types.article;
```
Add a new entry to the `example` collection:
```nix
config.collections.example.entry = {
# contents here
}
```
2024-10-11 21:38:57 +02:00
'';
type = with types; attrsOf (submodule ({ name, config, ... }: {
options = {
type = mkOption {
description = "Type of entries in the collection";
type = types.deferredModule;
2024-10-11 17:11:48 +02:00
};
2024-10-11 21:38:57 +02:00
entry = mkOption {
description = "An entry in the collection";
2024-10-12 11:27:51 +02:00
type = types.collection (types.submodule ({
2024-10-11 21:38:57 +02:00
_module.args.collection = config.entry;
_module.args.collectionName = name;
imports = [ config.type ];
}));
2024-10-11 17:11:48 +02:00
};
};
}));
2024-10-11 21:38:57 +02:00
};
2024-10-11 17:11:48 +02:00
}