forked from Fediversity/fediversity.eu
Compare commits
5 commits
064dd4041c
...
61726ab328
Author | SHA1 | Date | |
---|---|---|---|
61726ab328 | |||
b2b104e1e4 | |||
6fce43f880 | |||
e6fb3278c6 | |||
732ee62eed |
|
@ -1,4 +1,4 @@
|
|||
{ config, ... }:
|
||||
{ config, lib, ... }:
|
||||
let
|
||||
inherit (config) pages;
|
||||
in
|
||||
|
@ -6,11 +6,12 @@ in
|
|||
imports = [
|
||||
./grants.nix
|
||||
./fediversity.nix
|
||||
./nlnet.nix
|
||||
./nordunet.nix
|
||||
./tweag.nix
|
||||
./oid.nix
|
||||
];
|
||||
]
|
||||
++
|
||||
lib.fileset.toList ./partners
|
||||
++
|
||||
lib.fileset.toList ./news
|
||||
;
|
||||
|
||||
pages.index = {
|
||||
title = "Fediversity";
|
||||
|
@ -32,7 +33,7 @@ in
|
|||
|
||||
${pages.grants.summary}
|
||||
|
||||
[Learn more about our grants](${pages.grants})
|
||||
[Learn more about Fediversity grants](${pages.grants})
|
||||
|
||||
# Consortium
|
||||
|
||||
|
@ -43,8 +44,19 @@ in
|
|||
|
||||
${partner.description}
|
||||
|
||||
[Read more about ${partner.title}](./${partner})
|
||||
[Read more about ${partner.title}](${partner})
|
||||
'') (with pages; [ nlnet oid tweag nordunet ]))}
|
||||
|
||||
# News
|
||||
|
||||
${
|
||||
let
|
||||
sorted = with lib; reverseList (sortOn (entry: entry.date) config.collections.news.entry);
|
||||
in
|
||||
lib.join "\n" (map (article: ''
|
||||
- ${article.date} [${article.title}](${article})
|
||||
'') sorted)
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
23
content/news/nordunet-conference.nix
Normal file
23
content/news/nordunet-conference.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{ ... }:
|
||||
{
|
||||
collections.news.entry = {
|
||||
title = "Nordunet Conference 2024";
|
||||
description = "Report from the NORDUnet Conference 2024";
|
||||
date = "2024-09-17";
|
||||
author = "Laurens Hof";
|
||||
locations = [
|
||||
"nordunet-conference-2024.html"
|
||||
];
|
||||
body = ''
|
||||
Fediversity was represented in Bergen at the Nordunet Conference for 2024, with both the Internet Discourse Foundation and Nordunet themselves being present. This was a great opportunity for the different organisations in the consortium to meet with each other and exchange ideas.
|
||||
|
||||
One of those new ideas that came out of the conference is to think about offering [EduMEET](https://edumeet.org/) as a part of Fediversity. EduMEET is an open source video conferencing platform that is build for and by the Research and Education community. EduMEET allows for the possibility of recording conference calls, but does not offer an easy place to host these recordings. PeerTube is already mature fediverse software that offers video hosting. Combining these two pieces of software in the offering to onboard public organisations can make it easier to offer a complete package for the organisations. It can potentially help lower the barrier of entry, while at the same time making it more attractive for public education organisations to start using fediverse software.
|
||||
|
||||
Fediversity is now starting to explore if and how efforts with Nordunet to promote EduMEET can be combined with Fediversity's (and thus Nordunet!) project to promote the fediverse.
|
||||
|
||||
Another aspect that came out of the conference is the possibility to use [Argus](https://openargus.org/) as a real-time monitoring tool as part of our hosting stack that we're building. How to do real-time monitoring was so far still unclear in our plans for building a Nix panel, but Argus might just be the open source tool we're looking for.
|
||||
|
||||
It was exciting to meet so many people in the community that are all working towards building better digital systems for public organisations, and we're proud to contribute our small piece to a much larger puzzle. Hope to meet more of you all soon!
|
||||
'';
|
||||
};
|
||||
}
|
19
content/news/project-launch.nix
Normal file
19
content/news/project-launch.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{ ... }:
|
||||
{
|
||||
collections.news.entry = {
|
||||
title = "Fediversity project publicly announced";
|
||||
description = "The Fediversity project has officially been announced";
|
||||
date = "2024-01-01";
|
||||
author = "Laurens Hof";
|
||||
locations = [
|
||||
"fediversity-announced.html"
|
||||
];
|
||||
body = ''
|
||||
The Consortium behind the Fediversity project announces that the project has officially been started. NLnet, Tweag, NorduNet and the Open Internet Discourse Foundation are working together to build a new service for cloud hosters.
|
||||
|
||||
Fediversity is a comprehensive effort to bring easy-to-use, hosted cloud services with service portability and personal freedom at their core to everyone. It wants to provide everyone with high-quality, secure IT systems for everyday use. Without tracking, without exploitation, in a way that runs everywhere and scales effortlessly. Fediversity is based on NixOS, a disruptive Linux distribution with a unique approach to package and configuration management. Built on top of the Nix package manager, NixOS is completely declarative, makes upgrading systems reliable, and has many other advantages. Because it is reproducible, it is ideally suited for complex deployment scenario's where consistent behaviour, stability and configurability matter.
|
||||
|
||||
Fediversity has received funding from the European Union’s Horizon Europe research and innovation programme under grant agreement No. 101136078.
|
||||
'';
|
||||
};
|
||||
}
|
19
content/news/publicspaces-conference-2024.nix
Normal file
19
content/news/publicspaces-conference-2024.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{ ... }:
|
||||
{
|
||||
collections.news.entry = {
|
||||
title = "PublicSpaces Conference 2024";
|
||||
description = "Report from the PublicSpaces Conference 2024 - 'Take Back the Internet'";
|
||||
date = "2024-07-30";
|
||||
author = "Laurens Hof";
|
||||
locations = [
|
||||
"publicspaces-conference-2024.html"
|
||||
];
|
||||
body = ''
|
||||
PublicSpaces and Waag Futurelabs recently held their yearly conference in Amsterdam, titled 'Taking Back the Internet'. PublicSpaces is a network of public organisations fighting for an internet based on public values. The Fediversity Project attended, to share ideas, and learn more about how people and organisations think about an ethical internet. If you are interested, you can view all sessions [here](https://conference.publicspaces.net/en/archive/pubconf2024) (hosted on PeerTube!).
|
||||
|
||||
Alexandra van Huffelen, who was Dutch Secretary of State of Digitalisation until last month, gave the opening talk to discuss digitalisation and public values. In the talk, van Huffelen said that the Netherlands has a prominent lead in the EU with the promotion of public values in the digital infrastructure. Van Huffelen has been a prominent supporter of open standards and decentralisation, and has pushed the usage of Mastodon within the Dutch government, which fits well with the goals and vision of the Fediversity project. Project Lead Koen de Jonge took the opportunity shortly before the talk to hand van Huffelen a Mastodon pin, which she proudly wore during her talk, as you can see in the header image!
|
||||
|
||||
There were quite some other talks about the Fediverse as well, discussing how to move the space forward. The goal of the Fediversity Project is to provide the technological infrastructure that makes it easier for people to join an open, free and fair social internet. The strength of Fediversity is in our technological capabilities, making the infrastructure more accessible. For our project to be successful, we also need a social infrastructure, that teaches people what it is and how it is beneficial for them, and how to get them on board. We also need public organisations to lead by example. Both of these social aspects of growing the fediverse were on full display during the PublicSpaces conference, and there is a real enthusiasm in growing the social internet. Fediversity is a strong supporter of organisations like PublicSpaces; while organisations like PublicSpaces help facilitate people and organisations with their thinking about why they should join the fediverse, and which steps should they take, Fediversity can provide the technological infrastructure that makes it all as easy as possible.
|
||||
'';
|
||||
};
|
||||
}
|
19
content/news/tech-session.nix
Normal file
19
content/news/tech-session.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{ ... }:
|
||||
{
|
||||
collections.news.entry = {
|
||||
title = "Fediversity tech session";
|
||||
description = "Fediversity tech session - NixOS and Kubernetes";
|
||||
date = "2024-08-05";
|
||||
author = "Laurens Hof";
|
||||
locations = [
|
||||
"tech-session.html"
|
||||
];
|
||||
body = ''
|
||||
Recently Fediversity hosted a tech session on NixOS and Kubernetes. We invited people within the community to discuss some design considerations of the Fediversity project with us.
|
||||
|
||||
One of the core ideas of Fediversity is to build on top of NixOS. NixOS makes upgrading system reliable, and complex deployment reproducable. One of the goals of the Fediversity project that provides an interesting challenge is to help people move away from the cloud hyperscalers. Offering our project on Kubernetes offers easy integration with the storage platforms of the hyperscalers. Easy integration with the hyperscalers is an explicit anti-goal of Fediversity, but we're not sure if we can offer all the functionality with NixOS yet.
|
||||
|
||||
You can check out our entire conversation right here.
|
||||
'';
|
||||
};
|
||||
}
|
19
content/news/website-launch.nix
Normal file
19
content/news/website-launch.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{ ... }:
|
||||
{
|
||||
collections.news.entry = {
|
||||
title = "Fediversity website launch";
|
||||
description = "Announcing our new website for the Fediversity project";
|
||||
date = "2024-05-15";
|
||||
author = "Laurens Hof";
|
||||
locations = [
|
||||
"website-launch.html"
|
||||
];
|
||||
body = ''
|
||||
We are pleased to introduce the launch of our new website dedicated to the Fediversity project.
|
||||
|
||||
The project is broad in scope, and the website reflects this. Whether you are a developer, an individual interested in the project, or want to know how the grant money is spend, the website keeps you up to date with everything you need to know.
|
||||
|
||||
We're excited to show you more of the progress of the Fediversity project, and how we can build a next generation of the open internet together!
|
||||
'';
|
||||
};
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
title: "Fediversity new website launch"
|
||||
description: "Announcing Our New Website for the Fediversity Project"
|
||||
date: 2024-05-15T05:00:00Z
|
||||
image: "/images/website-new.png"
|
||||
categories: ["News"]
|
||||
author: "Laurens Hof"
|
||||
draft: false
|
||||
---
|
||||
|
||||
We are pleased to introduce the launch of our new website dedicated to the Fediversity project.
|
||||
|
||||
The project is broad in scope, and the website reflects this. Whether you are a developer, an individual interested in the project, or want to know how the grant money is spend, the website keeps you up to date with everything you need to know.
|
||||
|
||||
We're excited to show you more of the progress of the Fediversity project, and how we can build a next generation of the open internet together!
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
title: "News"
|
||||
meta_title: "News"
|
||||
description: "News about Fediversity"
|
||||
---
|
|
@ -1,17 +0,0 @@
|
|||
---
|
||||
title: "Fediversity Tech Session"
|
||||
meta_title: ""
|
||||
description: "Fediversity Tech Session - NixOS and Kubernetes"
|
||||
date: 2024-08-05T05:00:00Z
|
||||
image: "/images/checkbox-illustration-scaled.png"
|
||||
categories: ["News"]
|
||||
author: "Laurens Hof"
|
||||
draft: false
|
||||
---
|
||||
|
||||
Recently Fediversity hosted a tech session on NixOS and Kubernetes. We invited people within the community to discuss some design considerations of the Fediversity project with us.
|
||||
|
||||
One of the core ideas of Fediversity is to build on top of NixOS. NixOS makes upgrading system reliable, and complex deployment reproducable. One of the goals of the Fediversity project that provides an interesting challenge is to help people move away from the cloud hyperscalers. Offering our project on Kubernetes offers easy integration with the storage platforms of the hyperscalers. Easy integration with the hyperscalers is an explicit anti-goal of Fediversity, but we're not sure if we can offer all the functionality with NixOS yet.
|
||||
|
||||
You can check out our entire conversation right here.
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
---
|
||||
title: "Nordunet Conference 2024"
|
||||
meta_title: ""
|
||||
description: "Nordunet Conference 2024"
|
||||
date: 2024-09-17T05:00:00Z
|
||||
image: "/images/bergen-airport.jpeg"
|
||||
categories: ["News"]
|
||||
author: "Laurens Hof"
|
||||
draft: false
|
||||
---
|
||||
|
||||
Fediversity was represented in Bergen at the Nordunet Conference for 2024, with both the Internet Discourse Foundation and Nordunet themselves being present. This was a great opportunity for the different organisations in the consortium to meet with each other and exchange ideas.
|
||||
|
||||
One of those new ideas that came out of the conference is to think about offering [EduMEET](https://edumeet.org/) as a part of Fediversity. EduMEET is an open source video conferencing platform that is build for and by the Research and Education community. EduMEET allows for the possibility of recording conference calls, but does not offer an easy place to host these recordings. PeerTube is already mature fediverse software that offers video hosting. Combining these two pieces of software in the offering to onboard public organisations can make it easier to offer a complete package for the organisations. It can potentially help lower the barrier of entry, while at the same time making it more attractive for public education organisations to start using fediverse software.
|
||||
|
||||
Fediversity is now starting to explore if and how efforts with Nordunet to promote EduMEET can be combined with Fediversity's (and thus Nordunet!) project to promote the fediverse.
|
||||
|
||||
Another aspect that came out of the conference is the possibility to use [Argus](https://openargus.org/) as a real-time monitoring tool as part of our hosting stack that we're building. How to do real-time monitoring was so far still unclear in our plans for building a Nix panel, but Argus might just be the open source tool we're looking for.
|
||||
|
||||
It was exciting to meet so many people in the community that are all working towards building better digital systems for public organisations, and we're proud to contribute our small piece to a much larger puzzle. Hope to meet more of you all soon!
|
|
@ -1,16 +0,0 @@
|
|||
---
|
||||
title: "Fediversity Project publicly announced"
|
||||
meta_title: ""
|
||||
description: "The Fediversity Project has officially been announced"
|
||||
date: 2024-01-01T05:00:00Z
|
||||
image: "/images/checkbox-illustration-scaled.png"
|
||||
categories: ["News"]
|
||||
author: "Laurens Hof"
|
||||
draft: false
|
||||
---
|
||||
|
||||
The Consortium behind the Fediversity project announces that the project has officially been started. NLnet, Tweag, NorduNet and the Open Internet Discourse Foundation are working together to build a new service for cloud hosters.
|
||||
|
||||
Fediversity is a comprehensive effort to bring easy-to-use, hosted cloud services with service portability and personal freedom at their core to everyone. It wants to provide everyone with high-quality, secure IT systems for everyday use. Without tracking, without exploitation, in a way that runs everywhere and scales effortlessly. Fediversity is based on NixOS, a disruptive Linux distribution with a unique approach to package and configuration management. Built on top of the Nix package manager, NixOS is completely declarative, makes upgrading systems reliable, and has many other advantages. Because it is reproducible, it is ideally suited for complex deployment scenario's where consistent behaviour, stability and configurability matter.
|
||||
|
||||
Fediversity has received funding from the European Union’s Horizon Europe research and innovation programme under grant agreement No. 101136078.
|
|
@ -1,16 +0,0 @@
|
|||
---
|
||||
title: "PublicSpaces Conference 2024"
|
||||
meta_title: ""
|
||||
description: "PublicSpaces Conference 2024 - 'Take Back the Internet'"
|
||||
date: 2024-07-30T05:00:00Z
|
||||
image: "/images/avhuffelenmastodonpin.jpg"
|
||||
categories: ["News"]
|
||||
author: "Laurens Hof"
|
||||
draft: false
|
||||
---
|
||||
|
||||
PublicSpaces and Waag Futurelabs recently held their yearly conference in Amsterdam, titled 'Taking Back the Internet'. PublicSpaces is a network of public organisations fighting for an internet based on public values. The Fediversity Project attended, to share ideas, and learn more about how people and organisations think about an ethical internet. If you are interested, you can view all sessions [here](https://conference.publicspaces.net/en/archive/pubconf2024) (hosted on PeerTube!).
|
||||
|
||||
Alexandra van Huffelen, who was Dutch Secretary of State of Digitalisation until last month, gave the opening talk to discuss digitalisation and public values. In the talk, van Huffelen said that the Netherlands has a prominent lead in the EU with the promotion of public values in the digital infrastructure. Van Huffelen has been a prominent supporter of open standards and decentralisation, and has pushed the usage of Mastodon within the Dutch government, which fits well with the goals and vision of the Fediversity project. Project Lead Koen de Jonge took the opportunity shortly before the talk to hand van Huffelen a Mastodon pin, which she proudly wore during her talk, as you can see in the header image!
|
||||
|
||||
There were quite some other talks about the Fediverse as well, discussing how to move the space forward. The goal of the Fediversity Project is to provide the technological infrastructure that makes it easier for people to join an open, free and fair social internet. The strength of Fediversity is in our technological capabilities, making the infrastructure more accessible. For our project to be successful, we also need a social infrastructure, that teaches people what it is and how it is beneficial for them, and how to get them on board. We also need public organisations to lead by example. Both of these social aspects of growing the fediverse were on full display during the PublicSpaces conference, and there is a real enthusiasm in growing the social internet. Fediversity is a strong supporter of organisations like PublicSpaces; while organisations like PublicSpaces help facilitate people and organisations with their thinking about why they should join the fediverse, and which steps should they take, Fediversity can provide the technological infrastructure that makes it all as easy as possible.
|
13
default.nix
13
default.nix
|
@ -6,16 +6,23 @@
|
|||
overlays = [ ];
|
||||
}
|
||||
, lib ? import "${sources.nixpkgs}/lib"
|
||||
,
|
||||
}:
|
||||
let
|
||||
lib' = final: prev: import ./lib.nix { lib = final; };
|
||||
lib'' = lib.extend lib';
|
||||
in
|
||||
{
|
||||
build =
|
||||
let
|
||||
result = pkgs.lib.evalModules {
|
||||
result = lib''.evalModules {
|
||||
modules = [
|
||||
./structure
|
||||
./content
|
||||
{ _module.args = { inherit pkgs; }; }
|
||||
{
|
||||
_module.args = {
|
||||
inherit pkgs;
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
in
|
||||
|
|
40
lib.nix
Normal file
40
lib.nix
Normal file
|
@ -0,0 +1,40 @@
|
|||
{ lib }:
|
||||
rec {
|
||||
/**
|
||||
Create a URL-safe slug from any string
|
||||
*/
|
||||
slug = str:
|
||||
let
|
||||
# Replace non-alphanumeric characters with hyphens
|
||||
replaced = join ""
|
||||
(
|
||||
builtins.map
|
||||
(c:
|
||||
if (c >= "a" && c <= "z") || (c >= "0" && c <= "9")
|
||||
then c
|
||||
else "-"
|
||||
)
|
||||
(with lib; stringToCharacters (toLower str)));
|
||||
|
||||
# Remove leading and trailing hyphens
|
||||
trimHyphens = s:
|
||||
let
|
||||
matched = builtins.match "(-*)([^-].*[^-]|[^-])(-*)" s;
|
||||
in
|
||||
with lib; optionalString (!isNull matched) (builtins.elemAt matched 1);
|
||||
|
||||
collapseHyphens = s:
|
||||
let
|
||||
result = builtins.replaceStrings [ "--" ] [ "-" ] s;
|
||||
in
|
||||
if result == s then s else collapseHyphens result;
|
||||
in
|
||||
trimHyphens (collapseHyphens replaced);
|
||||
|
||||
join = lib.concatStringsSep;
|
||||
|
||||
splitLines = s: with builtins; filter (x: !isList x) (split "\n" s);
|
||||
|
||||
indent = prefix: s:
|
||||
join "\n" (map (x: if x == "" then x else "${prefix}${x}") (splitLines s));
|
||||
}
|
|
@ -5,71 +5,130 @@ let
|
|||
types
|
||||
;
|
||||
cfg = config;
|
||||
types' = import ./types.nix { inherit lib; } // {
|
||||
article = { config, collectionName, ... }: {
|
||||
imports = [ types'.page ];
|
||||
options = {
|
||||
date = mkOption {
|
||||
description = "Publication date";
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
};
|
||||
author = mkOption {
|
||||
description = "Page author";
|
||||
type = with types; nullOr (either str (listOf str));
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
config.name = lib.slug config.title;
|
||||
config.outPath = "${collectionName}/${lib.head config.locations}";
|
||||
config.template = cfg.templates.article;
|
||||
};
|
||||
|
||||
page = { name, config, ... }: {
|
||||
options = {
|
||||
name = mkOption {
|
||||
description = "Symbolic name for the page, used as a human-readable identifier";
|
||||
type = types.str;
|
||||
default = name;
|
||||
};
|
||||
title = mkOption {
|
||||
description = "Page title";
|
||||
type = types.str;
|
||||
default = name;
|
||||
};
|
||||
locations = mkOption {
|
||||
description = ''
|
||||
List of historic output locations for the resulting file
|
||||
|
||||
The first element is the canonical location.
|
||||
All other elements are used to create redirects to the canonical location.
|
||||
'';
|
||||
type = with types; nonEmptyListOf str;
|
||||
};
|
||||
outPath = mkOption {
|
||||
description = ''
|
||||
Location of the page, used for transparently creating links
|
||||
'';
|
||||
type = types.str;
|
||||
default = lib.head config.locations;
|
||||
};
|
||||
description = mkOption {
|
||||
description = ''
|
||||
One-sentence description of page contents
|
||||
'';
|
||||
type = types.str;
|
||||
};
|
||||
summary = mkOption {
|
||||
description = ''
|
||||
One-paragraph summary of page contents
|
||||
'';
|
||||
type = types.str;
|
||||
};
|
||||
body = mkOption {
|
||||
description = ''
|
||||
Page contents in CommonMark
|
||||
'';
|
||||
type = types.str;
|
||||
};
|
||||
template = mkOption
|
||||
{
|
||||
description = ''
|
||||
Function that converts the page contents to files
|
||||
'';
|
||||
type = with types; functionTo (functionTo options.files.type);
|
||||
default = cfg.templates.page;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
# TODO: split out:
|
||||
# - extra module system types into lib'
|
||||
# - page and article types into their own module values under structure/${page,article}.nix
|
||||
# yes, actually. those types should probably be configurable
|
||||
config.collections.news.type = types'.article;
|
||||
|
||||
options.pages = mkOption {
|
||||
description = ''
|
||||
Collection of pages on the site
|
||||
'';
|
||||
type = with types; attrsOf (submodule ({ name, config, ... }:
|
||||
{
|
||||
options = {
|
||||
title = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
locations = mkOption {
|
||||
description = ''
|
||||
List of historic output locations for the resulting file
|
||||
type = with types; attrsOf (submodule types'.page);
|
||||
};
|
||||
|
||||
The first element is the canonical location.
|
||||
All other elements are used to create redirects to the canonical location.
|
||||
'';
|
||||
type = with types; nonEmptyListOf str;
|
||||
options.collections = mkOption
|
||||
{
|
||||
description = ''
|
||||
Named collections of unnamed pages
|
||||
'';
|
||||
type = with types; attrsOf (submodule ({ name, config, ... }: {
|
||||
options = {
|
||||
type = mkOption {
|
||||
description = "Type of entries in the collection";
|
||||
type = types.deferredModule;
|
||||
};
|
||||
outPath = mkOption {
|
||||
description = ''
|
||||
Canonical location of the page
|
||||
'';
|
||||
type = types.str;
|
||||
default = lib.head config.locations;
|
||||
entry = mkOption {
|
||||
description = "An entry in the collection";
|
||||
type = types'.collection (types.submodule ({
|
||||
_module.args.collection = config.entry;
|
||||
_module.args.collectionName = name;
|
||||
imports = [ config.type ];
|
||||
}));
|
||||
};
|
||||
description = mkOption {
|
||||
description = ''
|
||||
One-sentence description of page contents
|
||||
'';
|
||||
type = types.str;
|
||||
};
|
||||
summary = mkOption {
|
||||
description = ''
|
||||
One-paragraph summary of page contents
|
||||
'';
|
||||
type = types.str;
|
||||
};
|
||||
body = mkOption {
|
||||
description = ''
|
||||
Page contents in CommonMark
|
||||
'';
|
||||
type = types.str;
|
||||
};
|
||||
template = mkOption
|
||||
{
|
||||
description = ''
|
||||
Function that converts the page contents to files
|
||||
'';
|
||||
type = with types; functionTo (functionTo (functionTo options.files.type));
|
||||
default = cfg.templates.default;
|
||||
};
|
||||
};
|
||||
}));
|
||||
};
|
||||
};
|
||||
|
||||
options.templates = mkOption {
|
||||
description = ''
|
||||
Collection of named functions to convert page contents to files
|
||||
|
||||
Each template function takes the complete site `config` and the page data structure.
|
||||
'';
|
||||
type = with types; attrsOf (functionTo (functionTo (functionTo options.files.type)));
|
||||
type = with types; attrsOf (functionTo (functionTo options.files.type));
|
||||
};
|
||||
config.templates.default =
|
||||
config.templates =
|
||||
let
|
||||
commonmark = name: markdown: pkgs.runCommand "${name}.html"
|
||||
{
|
||||
|
@ -78,10 +137,10 @@ in
|
|||
cmark ${builtins.toFile "${name}.md" markdown} > $out
|
||||
'';
|
||||
in
|
||||
lib.mkDefault
|
||||
(config: name: page: {
|
||||
# TODO: create static redirects from the tail
|
||||
${lib.head page.locations} = builtins.toFile "${name}.html" ''
|
||||
{
|
||||
page = lib.mkDefault (config: page: {
|
||||
# TODO: create static redirects from `tail page.locations`
|
||||
${page.outPath} = builtins.toFile "${page.name}.html" ''
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
|
@ -90,14 +149,39 @@ in
|
|||
|
||||
<title>${page.title}</title>
|
||||
<meta name="description" content="${page.description}" />
|
||||
<link rel="canonical" href="${lib.head page.locations}" />
|
||||
<link rel="canonical" href="${page.outPath}" />
|
||||
</head>
|
||||
<body>
|
||||
${builtins.readFile (commonmark name page.body)}
|
||||
${lib.indent " " (builtins.readFile (commonmark page.name page.body))}
|
||||
<body>
|
||||
</html>
|
||||
'';
|
||||
});
|
||||
article = lib.mkDefault (config: page: {
|
||||
# TODO: create static redirects from `tail page.locations`
|
||||
${page.outPath} = builtins.toFile "${page.name}.html" ''
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<title>${page.title}</title>
|
||||
<meta name="description" content="${page.description}" />
|
||||
${with lib;
|
||||
if ! isNull page.author then
|
||||
''<meta name="author" content="${if isList page.author then join ", " page.author else page.author}" />''
|
||||
else ""
|
||||
}
|
||||
<link rel="canonical" href="${page.outPath}" />
|
||||
</head>
|
||||
<body>
|
||||
${lib.indent " " (builtins.readFile (commonmark page.name page.body))}
|
||||
<body>
|
||||
</html>
|
||||
'';
|
||||
});
|
||||
};
|
||||
|
||||
options.files = mkOption {
|
||||
description = ''
|
||||
|
@ -108,9 +192,27 @@ in
|
|||
'';
|
||||
type = with types; attrsOf path;
|
||||
};
|
||||
config.files = lib.concatMapAttrs
|
||||
(name: page: page.template config name page)
|
||||
config.pages;
|
||||
config.files =
|
||||
let
|
||||
pages = lib.concatMapAttrs
|
||||
(name: page: page.template config page)
|
||||
config.pages;
|
||||
collections =
|
||||
let
|
||||
byCollection = with lib; mapAttrs
|
||||
(_: collection:
|
||||
map (entry: entry.template config entry) collection.entry
|
||||
)
|
||||
config.collections;
|
||||
in
|
||||
with lib; concatMapAttrs
|
||||
(collection: entries:
|
||||
foldl' (acc: entry: acc // entry) { } entries
|
||||
)
|
||||
byCollection;
|
||||
in
|
||||
pages // collections;
|
||||
|
||||
|
||||
options.build = mkOption {
|
||||
description = ''
|
||||
|
@ -121,7 +223,7 @@ in
|
|||
let
|
||||
script = ''
|
||||
mkdir $out
|
||||
'' + lib.concatStringsSep "\n" copy;
|
||||
'' + lib.join "\n" copy;
|
||||
copy = lib.mapAttrsToList
|
||||
(
|
||||
path: file: ''
|
||||
|
|
47
structure/types.nix
Normal file
47
structure/types.nix
Normal file
|
@ -0,0 +1,47 @@
|
|||
{ lib, ... }:
|
||||
let
|
||||
inherit (lib) types;
|
||||
in
|
||||
rec {
|
||||
collection = elemType:
|
||||
let
|
||||
unparenthesize = class: class == "noun";
|
||||
desc = type:
|
||||
types.optionDescriptionPhrase unparenthesize type;
|
||||
desc' = type:
|
||||
let
|
||||
typeDesc = types.optionDescriptionPhrase unparenthesize type;
|
||||
in
|
||||
if type.descriptionClass == "noun"
|
||||
then
|
||||
typeDesc + "s"
|
||||
else
|
||||
"many instances of ${typeDesc}";
|
||||
in
|
||||
types.mkOptionType {
|
||||
name = "collection";
|
||||
description = "separately specified ${desc elemType} for a collection of ${desc' elemType}";
|
||||
merge = loc: defs:
|
||||
map
|
||||
(def:
|
||||
let
|
||||
merged = lib.mergeDefinitions
|
||||
(loc ++ [ "[definition ${toString def.file}]" ])
|
||||
elemType
|
||||
[{ inherit (def) file; value = def.value; }];
|
||||
in
|
||||
if merged ? mergedValue then merged.mergedValue else merged.value
|
||||
)
|
||||
defs;
|
||||
check = elemType.check;
|
||||
getSubOptions = elemType.getSubOptions;
|
||||
getSubModules = elemType.getSubModules;
|
||||
substSubModules = m: collection (elemType.substSubModules m);
|
||||
functor = (lib.defaultFunctor "collection") // {
|
||||
type = collection;
|
||||
wrapped = elemType;
|
||||
payload = { };
|
||||
};
|
||||
nestedTypes.elemType = elemType;
|
||||
};
|
||||
}
|
Reference in a new issue