diff --git a/website/content/default.nix b/website/content/default.nix
index daccf44..f1d19ea 100644
--- a/website/content/default.nix
+++ b/website/content/default.nix
@@ -9,124 +9,160 @@ in
collections.news.type = cfg.content-types.article;
collections.events.type = cfg.content-types.event;
- pages.index = { config, link, ... }: {
- title = "Welcome to the Fediversity project";
- description = "Fediversity web site";
- summary = ''
- This web site hosts up-to-date information about the the NGI Zero Fediversity project.
- '';
- body = ''
- ${pages.fediversity.summary}
+ pages.index =
+ { config, link, ... }:
+ {
+ title = "Welcome to the Fediversity project";
+ description = "Fediversity web site";
+ summary = ''
+ This web site hosts up-to-date information about the the NGI Zero Fediversity project.
+ '';
+ body = ''
+ ${pages.fediversity.summary}
- [Learn more about Fediversity](${link pages.fediversity})
- '';
- outputs.html = (cfg.templates.html.page config).override (final: prev: {
- html = {
- head.title.text = "Fediversity";
- head.link.stylesheets = prev.html.head.link.stylesheets ++ [
- { href = "${link cfg.assets."index.css"}"; }
- ];
- body.content =
- let
- to-section = { heading, body, attrs ? { } }: {
- section = {
- heading.content = heading;
- inherit attrs;
- content = [
- (cfg.templates.html.markdown {
- name = "${config.name}-${lib.slug heading}";
- inherit body;
- })
- ];
- };
- };
- in
- [
- (lib.head prev.html.body.content)
- {
- section = {
- attrs = { };
- heading.content = config.title;
- content = [
- (cfg.templates.html.markdown { inherit (config) name body; })
- ]
- ++
- (map to-section [
+ [Learn more about Fediversity](${link pages.fediversity})
+ '';
+ outputs.html = (cfg.templates.html.page config).override (
+ final: prev: {
+ html = {
+ head.title.text = "Fediversity";
+ head.link.stylesheets = prev.html.head.link.stylesheets ++ [
+ { href = "${link cfg.assets."index.css"}"; }
+ ];
+ body.content =
+ let
+ to-section =
{
- heading = "Fediversity grants";
- body = ''
- ${pages.grants.summary}
-
- [Learn more about Fediversity grants](${link pages.grants})
- '';
- }
+ heading,
+ body,
+ attrs ? { },
+ }:
{
- heading = "Consortium";
- body = ''
- The Consortium behind the Fediversity project is a cooperation between NLnet, Open Internet Discourse Foundation, NORDUnet and Tweag.
+ section = {
+ heading.content = heading;
+ inherit attrs;
+ content = [
+ (cfg.templates.html.markdown {
+ name = "${config.name}-${lib.slug heading}";
+ inherit body;
+ })
+ ];
+ };
+ };
+ in
+ [
+ (lib.head prev.html.body.content)
+ {
+ section = {
+ attrs = { };
+ heading.content = config.title;
+ content =
+ [
+ (cfg.templates.html.markdown { inherit (config) name body; })
+ ]
+ ++ (map to-section [
+ {
+ heading = "Fediversity grants";
+ body = ''
+ ${pages.grants.summary}
- ${toString (map (partner: ''
- ### ${partner.title}
+ [Learn more about Fediversity grants](${link pages.grants})
+ '';
+ }
+ {
+ heading = "Consortium";
+ body = ''
+ The Consortium behind the Fediversity project is a cooperation between NLnet, Open Internet Discourse Foundation, NORDUnet and Tweag.
- ${partner.summary}
+ ${toString (
+ map
+ (partner: ''
+ ### ${partner.title}
- [Read more about ${partner.title}](${link partner})
- '') (with pages; [ nlnet oid tweag nordunet ]))}
- '';
- }
- {
- heading = "Fediverse explained";
- body = ''
- ${toString (map (role: ''
- ### ${role.title}
+ ${partner.summary}
- ${role.summary}
+ [Read more about ${partner.title}](${link partner})
+ '')
+ (
+ with pages;
+ [
+ nlnet
+ oid
+ tweag
+ nordunet
+ ]
+ )
+ )}
+ '';
+ }
+ {
+ heading = "Fediverse explained";
+ body = ''
+ ${toString (
+ map
+ (role: ''
+ ### ${role.title}
- [Read more about ${role.title}](${link role})
- '') (with pages; [ individuals developers european-commission ]))}
- '';
- }
- ]);
- };
- }
- ]
- ++
- (map to-section [
- {
- heading = "News";
- attrs = { class = [ "collection" ]; };
- body =
- let
- sorted = with lib; reverseList (sortOn (entry: entry.date) cfg.collections.news.entry);
- in
- lib.join "\n" (map
- (article: ''
- - ${article.date} [${article.title}](${link article})
- '')
- sorted);
- }
- {
- heading = "Events";
- attrs = { class = [ "collection" ]; };
- body =
- let
- sorted = with lib; reverseList (sortOn (entry: entry.start-date) cfg.collections.events.entry);
- in
- lib.join "\n" (map
- (article: ''
- - ${article.start-date} [${article.title}](${link article})
- '')
- sorted);
- }
- ]);
- };
+ ${role.summary}
- });
- };
+ [Read more about ${role.title}](${link role})
+ '')
+ (
+ with pages;
+ [
+ individuals
+ developers
+ european-commission
+ ]
+ )
+ )}
+ '';
+ }
+ ]);
+ };
+ }
+ ]
+ ++ (map to-section [
+ {
+ heading = "News";
+ attrs = {
+ class = [ "collection" ];
+ };
+ body =
+ let
+ sorted = with lib; reverseList (sortOn (entry: entry.date) cfg.collections.news.entry);
+ in
+ lib.join "\n" (
+ map (article: ''
+ - ${article.date} [${article.title}](${link article})
+ '') sorted
+ );
+ }
+ {
+ heading = "Events";
+ attrs = {
+ class = [ "collection" ];
+ };
+ body =
+ let
+ sorted = with lib; reverseList (sortOn (entry: entry.start-date) cfg.collections.events.entry);
+ in
+ lib.join "\n" (
+ map (article: ''
+ - ${article.start-date} [${article.title}](${link article})
+ '') sorted
+ );
+ }
+ ]);
+ };
- assets."index.css".path = with lib; builtins.toFile
- "index.css"
- ''
+ }
+ );
+ };
+
+ assets."index.css".path =
+ with lib;
+ builtins.toFile "index.css" ''
section h1, section h2, section h3
{
text-align: center;
diff --git a/website/content/events.nix b/website/content/events.nix
index 450c50f..6d92ffb 100644
--- a/website/content/events.nix
+++ b/website/content/events.nix
@@ -1,22 +1,26 @@
{ config, lib, ... }:
{
- pages.events = { link, ... }: rec {
- title = "Events";
- description = "Events related to the Fediverse and NixOS";
- summary = description;
- body =
- with lib;
- let
- events = map
- (event: with lib; ''
- ## [${event.title}](${link event})
+ pages.events =
+ { link, ... }:
+ rec {
+ title = "Events";
+ description = "Events related to the Fediverse and NixOS";
+ summary = description;
+ body =
+ with lib;
+ let
+ events = map (
+ event: with lib; ''
+ ## [${event.title}](${link event})
- ${event.start-date} ${optionalString (!isNull event.end-date && event.end-date != event.start-date) "to ${event.end-date}"} in ${event.location}
- '')
- config.collections.events.entry;
- in
- ''
- ${join "\n" events}
- '';
- };
+ ${event.start-date} ${
+ optionalString (!isNull event.end-date && event.end-date != event.start-date) "to ${event.end-date}"
+ } in ${event.location}
+ ''
+ ) config.collections.events.entry;
+ in
+ ''
+ ${join "\n" events}
+ '';
+ };
}
diff --git a/website/content/events/2024-11-zurich-zhf.nix b/website/content/events/2024-11-zurich-zhf.nix
index da7f225..ab0e567 100644
--- a/website/content/events/2024-11-zurich-zhf.nix
+++ b/website/content/events/2024-11-zurich-zhf.nix
@@ -1,23 +1,25 @@
{ config, lib, ... }:
{
- collections.events.entry = { link, ... }: {
- title = "NixOS 24.11 ZHF hackathon";
- name = "zhf-24-11";
- description = "NixOS 24.11 ZHF hackathon in Zürich";
- start-date = "2024-11-23";
- end-date = "2024-11-24";
- start-time = "10:00";
- end-time = "17:00";
- location = "OST Campus Rapperswil";
- body = ''
- The biannual [Zürich NixOS ZHF hackathon](https://zurich.nix.ug/) has become somewhat of an institution for maintaining the tradition of preparing the upcoming NixOS release.
+ collections.events.entry =
+ { link, ... }:
+ {
+ title = "NixOS 24.11 ZHF hackathon";
+ name = "zhf-24-11";
+ description = "NixOS 24.11 ZHF hackathon in Zürich";
+ start-date = "2024-11-23";
+ end-date = "2024-11-24";
+ start-time = "10:00";
+ end-time = "17:00";
+ location = "OST Campus Rapperswil";
+ body = ''
+ The biannual [Zürich NixOS ZHF hackathon](https://zurich.nix.ug/) has become somewhat of an institution for maintaining the tradition of preparing the upcoming NixOS release.
- The main goal of the two-day gathering is to bring down the number of build failures on the [continuous integration system Hydra](https://status.nixos.org/) before the release: ZHF stands for *Zero Hydra Failures*.
- It also presents a great opportunity to learn Nix, squash bugs together, get to know each other, discuss current events, and make plans for the future.
+ The main goal of the two-day gathering is to bring down the number of build failures on the [continuous integration system Hydra](https://status.nixos.org/) before the release: ZHF stands for *Zero Hydra Failures*.
+ It also presents a great opportunity to learn Nix, squash bugs together, get to know each other, discuss current events, and make plans for the future.
- This is the greatest event in the series so far, with more than 40 participants from all over Europe, including many high-profile contributors and maintainers in the Nix ecosystem.
+ This is the greatest event in the series so far, with more than 40 participants from all over Europe, including many high-profile contributors and maintainers in the Nix ecosystem.
- [Fediversity engineers attended](${link config.collections.news.by-name.zhf-24-11}) to present prototypes and exchange ideas with other developers.
- '';
- };
+ [Fediversity engineers attended](${link config.collections.news.by-name.zhf-24-11}) to present prototypes and exchange ideas with other developers.
+ '';
+ };
}
diff --git a/website/content/events/owc-annual-conference-2024.nix b/website/content/events/owc-annual-conference-2024.nix
index 39d495f..f44d520 100644
--- a/website/content/events/owc-annual-conference-2024.nix
+++ b/website/content/events/owc-annual-conference-2024.nix
@@ -1,24 +1,26 @@
{ ... }:
{
- collections.events.entry = { ... }: {
- title = "OW2con 2024";
- description = "OW2con is the annual European open source conference in Paris";
- start-date = "2024-06-11";
- end-date = "2024-06-12";
- start-time = "09:00";
- end-time = "18:00";
- location = "Paris-Chatillon";
- body = ''
- OW2con is the European open source conference organized by OW2.
- An international meeting of developpers, IT companies, academics and non-profit organizations, OW2con brings together the entire open source community, during two days of presentations ranging from tech topics to business and ethical issues of open source.
- It also offers a unique opportunity to establish contact with peers through friendly networking sessions.
- OW2con is [open](https://www.ngi.eu/event/open-source-community-annual-conference-2024/) to all, the event is free and all sessions are held in English.
+ collections.events.entry =
+ { ... }:
+ {
+ title = "OW2con 2024";
+ description = "OW2con is the annual European open source conference in Paris";
+ start-date = "2024-06-11";
+ end-date = "2024-06-12";
+ start-time = "09:00";
+ end-time = "18:00";
+ location = "Paris-Chatillon";
+ body = ''
+ OW2con is the European open source conference organized by OW2.
+ An international meeting of developpers, IT companies, academics and non-profit organizations, OW2con brings together the entire open source community, during two days of presentations ranging from tech topics to business and ethical issues of open source.
+ It also offers a unique opportunity to establish contact with peers through friendly networking sessions.
+ OW2con is [open](https://www.ngi.eu/event/open-source-community-annual-conference-2024/) to all, the event is free and all sessions are held in English.
- The OW2con’24 call for presentations is open.
- This year we are giving the highlight on the theme of open source funding:
- What are the current solutions for innovators, start-ups or ISVs to finance their development?
- Private or public financing?
- Are national and European public policies up to the challenges?
- '';
- };
+ The OW2con’24 call for presentations is open.
+ This year we are giving the highlight on the theme of open source funding:
+ What are the current solutions for innovators, start-ups or ISVs to finance their development?
+ Private or public financing?
+ Are national and European public policies up to the challenges?
+ '';
+ };
}
diff --git a/website/content/events/publicspaces-conference-2024.nix b/website/content/events/publicspaces-conference-2024.nix
index 35fbe7d..3f2af58 100644
--- a/website/content/events/publicspaces-conference-2024.nix
+++ b/website/content/events/publicspaces-conference-2024.nix
@@ -1,18 +1,20 @@
{ ... }:
{
- collections.events.entry = { ... }: {
- title = "PublicSpaces Conference 2024";
- description = "A conference by PublicSpaces, Taking Back the Internet.";
- start-date = "2024-06-06";
- end-date = "2024-06-07";
- start-time = "09:00";
- end-time = "18:00";
- location = "Pakhuis de Zwijger - Amsterdam";
- body = ''
- On June 6th and 7th, PublicSpaces and Waag Futurelab proudly present the fourth edition of the PublicSpaces conference under the theme 'Empowering the Internet'.
- Held at Pakhuis de Zwijger, this two-day event will feature panels, keynotes, roundtable discussions, lectures, as well as art and cultural showcases, all aimed at collectively shaping the rules for a more inclusive internet.
- Join us as we navigate towards a digital landscape where everyone has a voice.
- For more information, check out the [website](https://publicspaces.net/2024/02/01/save-the-date-publicspaces-conferentie-2024/)
- '';
- };
+ collections.events.entry =
+ { ... }:
+ {
+ title = "PublicSpaces Conference 2024";
+ description = "A conference by PublicSpaces, Taking Back the Internet.";
+ start-date = "2024-06-06";
+ end-date = "2024-06-07";
+ start-time = "09:00";
+ end-time = "18:00";
+ location = "Pakhuis de Zwijger - Amsterdam";
+ body = ''
+ On June 6th and 7th, PublicSpaces and Waag Futurelab proudly present the fourth edition of the PublicSpaces conference under the theme 'Empowering the Internet'.
+ Held at Pakhuis de Zwijger, this two-day event will feature panels, keynotes, roundtable discussions, lectures, as well as art and cultural showcases, all aimed at collectively shaping the rules for a more inclusive internet.
+ Join us as we navigate towards a digital landscape where everyone has a voice.
+ For more information, check out the [website](https://publicspaces.net/2024/02/01/save-the-date-publicspaces-conferentie-2024/)
+ '';
+ };
}
diff --git a/website/content/events/waag-state-internet-2024.nix b/website/content/events/waag-state-internet-2024.nix
index a4608bd..0c6d607 100644
--- a/website/content/events/waag-state-internet-2024.nix
+++ b/website/content/events/waag-state-internet-2024.nix
@@ -1,25 +1,27 @@
{ ... }:
{
- collections.events.entry = { ... }: {
- title = "State of the Internet 2024";
- description = "The State of the Internet 2024 by Waag";
- start-date = "2024-05-16";
- end-date = "2024-05-16";
- start-time = "18:00";
- end-time = "20:00";
- location = "OBA Oosterdok - Amsterdam";
- body = ''
- Join us at the State of the Internet 2024, where Waag Futurelab, alongside the Municipality of Amsterdam and the OBA, delves into the depths of the online realm.
- Featuring Kim van Sparrentak, Member of the European Parliament, discussing Europe's efforts to regulate Big Tech and enhance digital rights.
- Explore the impact of pivotal European laws like the GDPR and AI Act while celebrating 30 years of Waag Futurelab's dedication to democratizing technology access for all.
+ collections.events.entry =
+ { ... }:
+ {
+ title = "State of the Internet 2024";
+ description = "The State of the Internet 2024 by Waag";
+ start-date = "2024-05-16";
+ end-date = "2024-05-16";
+ start-time = "18:00";
+ end-time = "20:00";
+ location = "OBA Oosterdok - Amsterdam";
+ body = ''
+ Join us at the State of the Internet 2024, where Waag Futurelab, alongside the Municipality of Amsterdam and the OBA, delves into the depths of the online realm.
+ Featuring Kim van Sparrentak, Member of the European Parliament, discussing Europe's efforts to regulate Big Tech and enhance digital rights.
+ Explore the impact of pivotal European laws like the GDPR and AI Act while celebrating 30 years of Waag Futurelab's dedication to democratizing technology access for all.
- The event takes place at:
+ The event takes place at:
- OBA Oosterdok
- Oosterdokskade 143
- 1011 DK Amsterdam
+ OBA Oosterdok
+ Oosterdokskade 143
+ 1011 DK Amsterdam
- Registration available [here](https://waag.org/nl/event/de-staat-van-het-internet-2024-met-kim-van-sparrentak/).
- '';
- };
+ Registration available [here](https://waag.org/nl/event/de-staat-van-het-internet-2024-met-kim-van-sparrentak/).
+ '';
+ };
}
diff --git a/website/content/navigation.nix b/website/content/navigation.nix
index 770fe29..2beb657 100644
--- a/website/content/navigation.nix
+++ b/website/content/navigation.nix
@@ -6,16 +6,33 @@ in
menus.main = {
label = "Main";
items = [
- { page = pages.index // { title = "Start"; }; }
+ {
+ page = pages.index // {
+ title = "Start";
+ };
+ }
{
menu.label = "For you";
- menu.items = map (page: { inherit page; })
- (with pages; [ individuals developers european-commission ]);
+ menu.items = map (page: { inherit page; }) (
+ with pages;
+ [
+ individuals
+ developers
+ european-commission
+ ]
+ );
}
{
menu.label = "Consortium";
- menu.items = map (page: { inherit page; })
- (with pages; [ nlnet oid tweag nordunet ]);
+ menu.items = map (page: { inherit page; }) (
+ with pages;
+ [
+ nlnet
+ oid
+ tweag
+ nordunet
+ ]
+ );
}
{ page = pages.fediversity; }
{ page = pages.grants; }
diff --git a/website/content/news.nix b/website/content/news.nix
index b689cf6..96d7c16 100644
--- a/website/content/news.nix
+++ b/website/content/news.nix
@@ -1,24 +1,24 @@
{ config, lib, ... }:
{
- pages.news = { link, ... }: rec {
- title = "News";
- description = "News about Fediversity";
- summary = description;
- body =
- with lib;
- let
- news = map
- (article: ''
+ pages.news =
+ { link, ... }:
+ rec {
+ title = "News";
+ description = "News about Fediversity";
+ summary = description;
+ body =
+ with lib;
+ let
+ news = map (article: ''
## [${article.title}](${link article})
${article.date} by ${article.author}
${article.summary}
- '')
- config.collections.news.entry;
- in
- ''
- ${join "\n\n" news}
- '';
- };
+ '') config.collections.news.entry;
+ in
+ ''
+ ${join "\n\n" news}
+ '';
+ };
}
diff --git a/website/content/news/2024-11-zurich-zhf.nix b/website/content/news/2024-11-zurich-zhf.nix
index 08d1202..84a8a05 100644
--- a/website/content/news/2024-11-zurich-zhf.nix
+++ b/website/content/news/2024-11-zurich-zhf.nix
@@ -1,22 +1,24 @@
{ config, lib, ... }:
{
- collections.news.entry = { link, ... }: rec {
- name = "zhf-24-11";
- title = "NixOS 24.11 release hackathon and workshop";
- description = "Fediversity engineers met in Zürich at a NixOS 24.11 ZHF hackathon";
- date = "2024-11-28";
- author = "Valentin Gagarin";
- summary = ''
- Fediversity engineers met in Zürich at a [NixOS 24.11 ZHF hackathon](${link config.collections.events.by-name.zhf-24-11}) to present prototypes and exchange ideas with the Nix community.
- '';
- body = ''
- ${summary}
+ collections.news.entry =
+ { link, ... }:
+ rec {
+ name = "zhf-24-11";
+ title = "NixOS 24.11 release hackathon and workshop";
+ description = "Fediversity engineers met in Zürich at a NixOS 24.11 ZHF hackathon";
+ date = "2024-11-28";
+ author = "Valentin Gagarin";
+ summary = ''
+ Fediversity engineers met in Zürich at a [NixOS 24.11 ZHF hackathon](${link config.collections.events.by-name.zhf-24-11}) to present prototypes and exchange ideas with the Nix community.
+ '';
+ body = ''
+ ${summary}
- Robert held a lightning talk on the design of [NixOps4](https://github.com/nixops4/nixops4), which is currently in the prototype stage of development.
- Before that, Nicolas had already shown an internal demonstration that NixOps4 is capable of deploying multiple NixOS services in the Fediversity test environment.
+ Robert held a lightning talk on the design of [NixOps4](https://github.com/nixops4/nixops4), which is currently in the prototype stage of development.
+ Before that, Nicolas had already shown an internal demonstration that NixOps4 is capable of deploying multiple NixOS services in the Fediversity test environment.
- In the afternoon, Robert, Valentin, and Koen got together with Eli from [Thymis](https://thymis.io) and Johannes from [Clan](https://clan.lol/) to walk each other through the architecture of their respective systems.
- This was an extraordinarily fruitful encounter that helped us to identify overlaps and potential for future collaboration!
- '';
- };
+ In the afternoon, Robert, Valentin, and Koen got together with Eli from [Thymis](https://thymis.io) and Johannes from [Clan](https://clan.lol/) to walk each other through the architecture of their respective systems.
+ This was an extraordinarily fruitful encounter that helped us to identify overlaps and potential for future collaboration!
+ '';
+ };
}
diff --git a/website/content/news/project-launch.nix b/website/content/news/project-launch.nix
index 63472b6..30a773c 100644
--- a/website/content/news/project-launch.nix
+++ b/website/content/news/project-launch.nix
@@ -1,19 +1,21 @@
{ config, lib, ... }:
{
- collections.news.entry = { link, ... }: {
- title = "Fediversity project publicly announced";
- description = "The Fediversity project has officially been announced";
- date = "2024-01-01";
- author = "Laurens Hof";
- summary = ''
- We are pleased to introduce the launch of our new website dedicated to the Fediversity project.
- '';
- 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.
+ collections.news.entry =
+ { link, ... }:
+ {
+ title = "Fediversity project publicly announced";
+ description = "The Fediversity project has officially been announced";
+ date = "2024-01-01";
+ author = "Laurens Hof";
+ summary = ''
+ We are pleased to introduce the launch of our new website dedicated to the Fediversity project.
+ '';
+ 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 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.
- '';
- };
+ Fediversity has received funding from the European Union’s Horizon Europe research and innovation programme under grant agreement No. 101136078.
+ '';
+ };
}
diff --git a/website/default.nix b/website/default.nix
index f68ec04..258d1ff 100644
--- a/website/default.nix
+++ b/website/default.nix
@@ -1,14 +1,16 @@
-{ sources ? import ../npins
-, system ? builtins.currentSystem
-, pkgs ? import sources.nixpkgs {
+{
+ sources ? import ../npins,
+ system ? builtins.currentSystem,
+ pkgs ? import sources.nixpkgs {
inherit system;
config = { };
overlays = [ ];
- }
-, lib ? import "${sources.nixpkgs}/lib"
+ },
+ lib ? import "${sources.nixpkgs}/lib",
}:
let
- lib' = final: prev:
+ lib' =
+ final: prev:
let
new = import ./lib.nix { lib = final; };
in
@@ -37,15 +39,21 @@ rec {
let
run-tests = pkgs.writeShellApplication {
name = "run-tests";
- text = with pkgs; with lib; ''
- ${getExe nix-unit} ${toString ./tests.nix} "$@"
- '';
+ text =
+ with pkgs;
+ with lib;
+ ''
+ ${getExe nix-unit} ${toString ./tests.nix} "$@"
+ '';
};
test-loop = pkgs.writeShellApplication {
name = "test-loop";
- text = with pkgs; with lib; ''
- ${getExe watchexec} -w ${toString ./.} -- ${getExe nix-unit} ${toString ./tests.nix}
- '';
+ text =
+ with pkgs;
+ with lib;
+ ''
+ ${getExe watchexec} -w ${toString ./.} -- ${getExe nix-unit} ${toString ./tests.nix}
+ '';
};
devmode = pkgs.devmode.override {
buildArgs = "${toString ./.} -A build --show-trace";
@@ -62,7 +70,9 @@ rec {
};
inherit sources pkgs;
- tests = with pkgs; with lib;
+ tests =
+ with pkgs;
+ with lib;
let
source = fileset.toSource {
root = ../.;
diff --git a/website/lib.nix b/website/lib.nix
index 148c1da..f18adf2 100644
--- a/website/lib.nix
+++ b/website/lib.nix
@@ -1,21 +1,25 @@
{ lib }:
rec {
- template = g: f: x:
+ template =
+ g: f: x:
let
base = f x;
result = g base;
in
- result // {
- override = new:
+ result
+ // {
+ override =
+ new:
let
base' =
- if lib.isFunction new
- then lib.recursiveUpdate base (new base' base)
+ if lib.isFunction new then
+ lib.recursiveUpdate base (new base' base)
else
lib.recursiveUpdate base new;
result' = g base';
in
- result' // {
+ result'
+ // {
override = new: (template g (x': base') x).override new;
};
};
@@ -28,7 +32,8 @@ rec {
replaceStringRec "--" "-" "hello-----world"
=> "hello-world"
*/
- replaceStringsRec = from: to: string:
+ replaceStringsRec =
+ from: to: string:
let
replaced = lib.replaceStrings [ from ] [ to ] string;
in
@@ -37,25 +42,24 @@ rec {
/**
Create a URL-safe slug from any string
*/
- slug = str:
+ 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)));
+ 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:
+ trimHyphens =
+ s:
let
matched = builtins.match "(-*)([^-].*[^-]|[^-])(-*)" s;
in
- with lib; optionalString (!isNull matched) (builtins.elemAt matched 1);
+ with lib;
+ optionalString (!isNull matched) (builtins.elemAt matched 1);
in
trimHyphens (replaceStringsRec "--" "-" replaced);
@@ -64,9 +68,11 @@ rec {
/**
Trim trailing spaces and squash non-leading spaces
*/
- trim = string:
+ trim =
+ string:
let
- trimLine = line:
+ trimLine =
+ line:
with lib;
let
# separate leading spaces from the rest
@@ -76,8 +82,7 @@ rec {
# drop trailing spaces
body = head (split " *$" rest);
in
- if body == "" then "" else
- spaces + replaceStringsRec " " " " body;
+ if body == "" then "" else spaces + replaceStringsRec " " " " body;
in
join "\n" (map trimLine (splitLines string));
@@ -85,84 +90,95 @@ rec {
splitLines = s: with builtins; filter (x: !isList x) (split "\n" s);
- indent = prefix: s:
+ indent =
+ prefix: s:
with lib.lists;
let
lines = splitLines s;
in
- join "\n" (
- [ (head lines) ]
- ++
- (map (x: if x == "" then x else "${prefix}${x}") (tail lines))
- );
+ join "\n" ([ (head lines) ] ++ (map (x: if x == "" then x else "${prefix}${x}") (tail lines)));
- relativePath = path1': path2':
+ relativePath =
+ path1': path2':
let
inherit (lib.path) subpath;
- inherit (lib) lists length take drop min max;
+ inherit (lib)
+ lists
+ length
+ take
+ drop
+ min
+ max
+ ;
path1 = subpath.components path1';
prefix1 = take (length path1 - 1) path1;
path2 = subpath.components path2';
prefix2 = take (length path2 - 1) path2;
- commonPrefixLength = with lists;
- findFirstIndex (i: i.fst != i.snd)
- (min (length prefix1) (length prefix2))
- (zipLists prefix1 prefix2);
+ commonPrefixLength =
+ with lists;
+ findFirstIndex (i: i.fst != i.snd) (min (length prefix1) (length prefix2)) (
+ zipLists prefix1 prefix2
+ );
depth = max 0 (length prefix1 - commonPrefixLength);
- relativeComponents = with lists;
+ relativeComponents =
+ with lists;
[ "." ] ++ (replicate depth "..") ++ (drop commonPrefixLength path2);
in
join "/" relativeComponents;
/**
- Recursively list all Nix files from a directory, except the top-level `default.nix`
+ Recursively list all Nix files from a directory, except the top-level `default.nix`
- Useful for module system `imports` from a top-level module.
- **/
- nixFiles = dir: with lib.fileset;
- toList (difference
- (fileFilter ({ hasExt, ... }: hasExt "nix") dir)
- (dir + "/default.nix")
- );
+ Useful for module system `imports` from a top-level module.
+ *
+ */
+ nixFiles =
+ dir:
+ with lib.fileset;
+ toList (difference (fileFilter ({ hasExt, ... }: hasExt "nix") dir) (dir + "/default.nix"));
types = rec {
# arbitrarily nested attribute set where the leaves are of type `type`
# NOTE: this works for anything but attribute sets!
- recursiveAttrs = type: with lib.types;
+ recursiveAttrs =
+ type:
+ with lib.types;
# NOTE: due to how `either` works, the first match is significant,
# so if `type` happens to be an attrset, the typecheck will consider
# `type`, not `attrsOf`
attrsOf (either type (recursiveAttrs type));
# collection of unnamed items that can be added to item-wise, i.e. without wrapping the item in a list
- collection = elemType:
+ collection =
+ elemType:
let
unparenthesize = class: class == "noun";
- desc = type:
- types.optionDescriptionPhrase unparenthesize type;
- desc' = type:
+ desc = type: types.optionDescriptionPhrase unparenthesize type;
+ desc' =
+ type:
let
typeDesc = lib.types.optionDescriptionPhrase unparenthesize type;
in
- if type.descriptionClass == "noun"
- then
- typeDesc + "s"
- else
- "many instances of ${typeDesc}";
+ if type.descriptionClass == "noun" then typeDesc + "s" else "many instances of ${typeDesc}";
in
lib.types.mkOptionType {
name = "collection";
description = "separately specified ${desc elemType} for a collection of ${desc' elemType}";
- merge = loc: defs:
- map
- (def:
- elemType.merge (loc ++ [ "[definition ${toString def.file}]" ]) [{ inherit (def) file; value = def.value; }]
- )
- defs;
+ merge =
+ loc: defs:
+ map (
+ def:
+ elemType.merge (loc ++ [ "[definition ${toString def.file}]" ]) [
+ {
+ inherit (def) file;
+ value = def.value;
+ }
+ ]
+ ) defs;
check = elemType.check;
getSubOptions = elemType.getSubOptions;
getSubModules = elemType.getSubModules;
@@ -175,29 +191,34 @@ rec {
nestedTypes.elemType = elemType;
};
- listOfUnique = elemType:
+ listOfUnique =
+ elemType:
let
baseType = lib.types.listOf elemType;
in
- baseType // {
- merge = loc: defs:
+ baseType
+ // {
+ merge =
+ loc: defs:
let
# Keep track of which definition each value came from
- defsWithValues = map
- (def:
- map (v: { inherit (def) file; value = v; }) def.value
- )
- defs;
+ defsWithValues = map (
+ def:
+ map (v: {
+ inherit (def) file;
+ value = v;
+ }) def.value
+ ) defs;
flatDefs = lib.flatten defsWithValues;
# Check for duplicates while preserving source info
- seen = builtins.foldl'
- (acc: def:
- if lib.lists.any (v: v.value == def.value) acc
- then throw "The option `${lib.options.showOption loc}` has duplicate values (${toString def.value}) defined in ${def.file}"
- else acc ++ [ def ]
- ) [ ]
- flatDefs;
+ seen = builtins.foldl' (
+ acc: def:
+ if lib.lists.any (v: v.value == def.value) acc then
+ throw "The option `${lib.options.showOption loc}` has duplicate values (${toString def.value}) defined in ${def.file}"
+ else
+ acc ++ [ def ]
+ ) [ ] flatDefs;
in
map (def: def.value) seen;
};
diff --git a/website/presentation/default.nix b/website/presentation/default.nix
index a0d679e..8a20230 100644
--- a/website/presentation/default.nix
+++ b/website/presentation/default.nix
@@ -1,4 +1,10 @@
-{ config, options, lib, pkgs, ... }:
+{
+ config,
+ options,
+ lib,
+ pkgs,
+ ...
+}:
let
inherit (lib)
mkOption
@@ -8,13 +14,12 @@ in
{
imports = lib.nixFiles ./.;
- options.templates =
- mkOption {
- description = ''
- Collection of named helper functions for conversion different structured representations which can be rendered to a string
- '';
- type = with types; recursiveAttrs (functionTo (either str attrs));
- };
+ options.templates = mkOption {
+ description = ''
+ Collection of named helper functions for conversion different structured representations which can be rendered to a string
+ '';
+ type = with types; recursiveAttrs (functionTo (either str attrs));
+ };
options.files = mkOption {
description = ''
@@ -32,58 +37,64 @@ in
type = types.package;
default =
let
- script = ''
- mkdir $out
- '' + lib.join "\n" copy;
- copy = lib.mapAttrsToList
- (
- path: file: ''
- mkdir -p $out/$(dirname ${path})
- cp -r ${file} $out/${path}
- ''
- )
- config.files;
+ script =
+ ''
+ mkdir $out
+ ''
+ + lib.join "\n" copy;
+ copy = lib.mapAttrsToList (path: file: ''
+ mkdir -p $out/$(dirname ${path})
+ cp -r ${file} $out/${path}
+ '') config.files;
in
pkgs.runCommand "source" { } script;
};
# TODO: this is an artefact of exploration; needs to be adapted to actual use
- config.templates.table-of-contents = { config, ... }:
+ config.templates.table-of-contents =
+ { config, ... }:
let
- outline = { ... }: {
- options = {
- value = mkOption {
- # null denotes root
- type = with types; nullOr (either str (listOf (attrTag categories.phrasing)));
- subsections = mkOption {
- type = with types; listOf (submodule outline);
- default = with lib; map
- # TODO: go into depth manually here,
- # we don't want to pollute the DOM implementation
- (c: (lib.head (attrValues c)).outline)
- (filter (c: isAttrs c && (lib.head (attrValues c)) ? outline) config.content);
+ outline =
+ { ... }:
+ {
+ options = {
+ value = mkOption {
+ # null denotes root
+ type = with types; nullOr (either str (listOf (attrTag categories.phrasing)));
+ subsections = mkOption {
+ type = with types; listOf (submodule outline);
+ default =
+ with lib;
+ map
+ # TODO: go into depth manually here,
+ # we don't want to pollute the DOM implementation
+ (c: (lib.head (attrValues c)).outline)
+ (filter (c: isAttrs c && (lib.head (attrValues c)) ? outline) config.content);
+ };
+ };
+ __toString = mkOption {
+ type = with types; functionTo str;
+ # TODO: convert to HTML
+ default =
+ self:
+ lib.squash ''
+ ${if isNull self.value then "root" else self.value}
+ ${if self.subsections != [ ] then " " + lib.indent " " (lib.join "\n" self.subsections) else ""}
+ '';
};
};
- __toString = mkOption {
- type = with types; functionTo str;
- # TODO: convert to HTML
- default = self: lib.squash ''
- ${if isNull self.value then "root" else self.value}
- ${if self.subsections != [] then
- " " + lib.indent " " (lib.join "\n" self.subsections) else ""}
- '';
- };
};
- };
in
{
options.outline = mkOption {
type = types.submodule outline;
default = {
value = null;
- subsections = with lib;
- map (c: (lib.head (attrValues c)).outline)
- (filter (c: isAttrs c && (lib.head (attrValues c)) ? outline) config.content);
+ subsections =
+ with lib;
+ map (c: (lib.head (attrValues c)).outline) (
+ filter (c: isAttrs c && (lib.head (attrValues c)) ? outline) config.content
+ );
};
};
};
diff --git a/website/presentation/dom.nix b/website/presentation/dom.nix
index 1c06780..0911a7a 100644
--- a/website/presentation/dom.nix
+++ b/website/presentation/dom.nix
@@ -28,36 +28,46 @@ let
];
# base type for all DOM elements
- element = { ... }: {
- # TODO: add fields for upstream documentation references
- # TODO: programmatically generate documentation
- options = with lib; {
- categories = mkOption {
- type = types.listOfUnique (types.enum content-categories);
- };
- __toString = mkOption {
- internal = true;
- type = with types; functionTo str;
+ element =
+ { ... }:
+ {
+ # TODO: add fields for upstream documentation references
+ # TODO: programmatically generate documentation
+ options = with lib; {
+ categories = mkOption {
+ type = types.listOfUnique (types.enum content-categories);
+ };
+ __toString = mkOption {
+ internal = true;
+ type = with types; functionTo str;
+ };
};
};
- };
# options with types for all the defined DOM elements
- element-types = lib.mapAttrs
- (name: value: mkOption { type = submodule value; })
- elements;
+ element-types = lib.mapAttrs (name: value: mkOption { type = submodule value; }) elements;
# attrset of categories, where values are module options with the type of the
# elements that belong to these categories
- categories = with lib;
- genAttrs
- content-categories
- (category:
- (mapAttrs (_: e: mkOption { type = submodule e; })
- # HACK: don't evaluate the submodule types, just grab the config directly
- # TODO: we may want to do this properly and loop `categories` through the top-level `config`
- (filterAttrs (_: e: elem category (e { name = "dummy"; config = { }; }).config.categories) elements))
- );
+ categories =
+ with lib;
+ genAttrs content-categories (
+ category:
+ (mapAttrs (_: e: mkOption { type = submodule e; })
+ # HACK: don't evaluate the submodule types, just grab the config directly
+ # TODO: we may want to do this properly and loop `categories` through the top-level `config`
+ (
+ filterAttrs (
+ _: e:
+ elem category
+ (e {
+ name = "dummy";
+ config = { };
+ }).config.categories
+ ) elements
+ )
+ )
+ );
global-attrs = lib.mapAttrs (name: value: mkOption value) {
class = {
@@ -131,7 +141,8 @@ let
# https://html.spec.whatwg.org/multipage/document-sequences.html#valid-navigable-target-name-or-keyword
type =
let
- is-valid-target = s:
+ is-valid-target =
+ s:
let
inherit (lib) match;
has-lt = s: match ".*<.*" s != null;
@@ -140,14 +151,19 @@ let
in
has-valid-start s && !(has-lt s && has-tab-or-newline s);
in
- with types; either
- (enum [ "_blank" "_self" "_parent" "_top" ])
- (types.addCheck str is-valid-target)
- ;
+ with types;
+ either (enum [
+ "_blank"
+ "_self"
+ "_parent"
+ "_top"
+ ]) (types.addCheck str is-valid-target);
};
};
- mkAttrs = attrs: with lib;
+ mkAttrs =
+ attrs:
+ with lib;
mkOption {
type = submodule {
options = global-attrs // attrs;
@@ -155,28 +171,33 @@ let
default = { };
};
- print-attrs = with lib; attrs:
+ print-attrs =
+ with lib;
+ attrs:
# TODO: figure out how let attributes know how to print themselves without polluting the interface
let
- result = trim (join " "
- (mapAttrsToList
- # TODO: this needs to be smarter for boolean attributes
- # where the value must be written out explicitly.
- # probably the attribute itself should have its own `__toString`.
- (name: value:
- if isBool value then
- if value then name else ""
- # TODO: some attributes must be explicitly empty
- else optionalString (toString value != "") ''${name}="${toString value}"''
- )
- attrs)
+ result = trim (
+ join " " (
+ mapAttrsToList
+ # TODO: this needs to be smarter for boolean attributes
+ # where the value must be written out explicitly.
+ # probably the attribute itself should have its own `__toString`.
+ (
+ name: value:
+ if isBool value then
+ if value then name else ""
+ # TODO: some attributes must be explicitly empty
+ else
+ optionalString (toString value != "") ''${name}="${toString value}"''
+ )
+ attrs
+ )
);
in
- if attrs == null then throw "wat" else
- optionalString (stringLength result > 0) " " + result
- ;
+ if attrs == null then throw "wat" else optionalString (stringLength result > 0) " " + result;
- print-element = name: attrs: content:
+ print-element =
+ name: attrs: content:
with lib;
# TODO: be smarter about content to save some space and repetition at the call sites
squash (trim ''
@@ -187,472 +208,575 @@ let
print-element' = name: attrs: "<${name}${print-attrs attrs}>";
- toString-unwrap = e:
+ toString-unwrap =
+ e:
with lib;
- if isAttrs e
- then toString (head (attrValues e))
- else if isList e
- then toString (map toString-unwrap e)
- else e;
+ if isAttrs e then
+ toString (head (attrValues e))
+ else if isList e then
+ toString (map toString-unwrap e)
+ else
+ e;
elements = rec {
- document = { ... }: {
- imports = [ element ];
- options = {
- inherit (element-types) html;
- attrs = mkAttrs { };
- };
-
- config.categories = [ ];
- config.__toString = self: ''
-
- ${self.html}
- '';
- };
-
- html = { name, ... }: {
- imports = [ element ];
- options = {
- attrs = mkAttrs { };
- inherit (element-types) head body;
- };
-
- config.categories = [ ];
- config.__toString = self: print-element name self.attrs ''
- ${self.head}
- ${self.body}
- '';
- };
-
- head = { name, ... }: {
- imports = [ element ];
- options = with lib; {
- attrs = mkAttrs { };
- # https://html.spec.whatwg.org/multipage/semantics.html#the-head-element:concept-element-content-model
- # XXX: this doesn't implement the iframe srcdoc semantics
- # as those have questionable value and would complicate things a bit.
- # it should be possible though, by passing a flag via module arguments.
- inherit (element-types) title;
- base = mkOption {
- type = with types; nullOr (submodule base);
- default = null;
- };
- # https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-charset
- meta.charset = mkOption {
- # TODO: create programmatically from https://encoding.spec.whatwg.org/encodings.json
- type = types.enum [
- "utf-8"
- ];
- default = "utf-8";
- };
- # https://developer.mozilla.org/en-US/docs/Web/HTML/Viewport_meta_tag#viewport_width_and_screen_width
- # this should not exist and no one should ever have to think about it
- meta.viewport = mkOption {
- type = submodule ({ ... }: {
- # TODO: figure out how to render only non-default values
- options = {
- width = mkOption {
- type = with types; either
- (ints.between 1 10000)
- (enum [ "device-width" ]);
- default = "device-width"; # not default by standard
- };
- height = mkOption {
- type = with types; either
- (ints.between 1 10000)
- (enum [ "device-height" ]);
- default = "device-height"; # not default by standard (but seems to work if you don't set it)
- };
- initial-scale = mkOption {
- type = types.numbers.between 0.1 10;
- default = 1;
- };
- minimum-scale = mkOption {
- type = types.numbers.between 0.1 10;
- # TODO: render only as many digits as needed
- default = 0.1;
- };
- maximum-scale = mkOption {
- type = types.numbers.between 0.1 10;
- default = 10;
- };
- user-scalable = mkOption {
- type = types.bool;
- default = true;
- };
- interactive-widget = mkOption {
- type = types.enum [
- "resizes-visual"
- "resizes-content"
- "overlays-content"
- ];
- default = "resizes-visual";
- };
- };
- });
- default = { };
+ document =
+ { ... }:
+ {
+ imports = [ element ];
+ options = {
+ inherit (element-types) html;
+ attrs = mkAttrs { };
};
- meta.authors = mkOption {
- type = with types; listOf str;
- default = [ ];
- };
- meta.description = mkOption {
- type = with types; nullOr str;
- default = null;
- };
- # TODO: this one has more internal structure, e.g with hreflang
- # TODO: print in output
- link.canonical = mkOption {
- type = with types; nullOr str;
- default = null;
- };
- link.stylesheets = mkOption {
- type = types.listOf (submodule stylesheet);
- default = [ ];
- };
-
- # TODO: figure out `meta` elements
- # https://html.spec.whatwg.org/multipage/semantics.html#the-meta-element:concept-element-attributes
- # https://html.spec.whatwg.org/multipage/semantics.html#other-metadata-names
- };
-
- config.categories = [ ];
- config.__toString = self:
- with lib;
- print-element name self.attrs ''
- ${self.title}
- ${with lib; optionalString (!isNull self.base) self.base}
-
-
- ${/* https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-x-ua-compatible */
- ""}
-
-
-
-
-
- ${print-element' "meta" {
- name = "viewport";
- content = "${join ", " (mapAttrsToList (name: value: "${name}=${toString value}") self.meta.viewport) }";
- }}
-
- ${join "\n" (map
- (author: print-element' "meta" {
- name = "author";
- content = "${author}";
- })
- self.meta.authors)
- }
-
- ${join "\n" (map
- (stylesheet: print-element' "link" ({ rel = "stylesheet"; } // (removeAttrs stylesheet [ "categories" "__toString" ])))
- self.link.stylesheets)
- }
+ config.categories = [ ];
+ config.__toString = self: ''
+
+ ${self.html}
'';
- };
-
- title = { name, ... }: {
- imports = [ element ];
- options.attrs = mkAttrs { };
- options.text = mkOption {
- type = types.str;
};
- config.categories = [ "metadata" ];
- config.__toString = self: "<${name}${print-attrs self.attrs}>${self.text}${name}>";
- };
-
- base = { name, ... }: {
- imports = [ element ];
- # TODO: "A base element must have either an href attribute, a target attribute, or both."
- options = global-attrs // { inherit (attrs) href target; };
- config.categories = [ "metadata" ];
- config.__toString = self: "