PoC: build site from nix files

This commit is contained in:
Valentin Gagarin 2024-10-11 12:28:57 +02:00
parent 1157f1749d
commit df4b003879
37 changed files with 224 additions and 19 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
result

View file

@ -1,17 +0,0 @@
---
title: "Grants"
# meta title
meta_title: "Grants"
# meta description
description: "How to apply for grants as part of the Fediversity Project."
# save as draft
draft: false
---
Fediversity invites other people to join this ambitious development effort. It is a vast domain with many more challenges than what any preconceived effort could tackle by itself. This is why we invite your contribution to help us reshape the state of play, and together create an open, trustworthy and reliable internet for all.
This is your opportunity to make a real difference. You tell us how your project can help Fediversity go harder, better, faster, stronger. In order to enable you to make such contributions, NLnet will award 450 000 euro in small to medium-size R&D grants towards solutions that bring the next generation of social networks closer. NLnet is seeking project proposals between 5.000 and 50.000 euros — which should get you on your way.
Noteworthy fact: many projects which are to be deployed inside Fediversity were themselves bootstrapped on precisely such a grant from NGI, and now it is your turn.
For more information on how to apply, check the NLnet website.

19
content/fediversity.nix Normal file
View file

@ -0,0 +1,19 @@
rec {
title = "Fediversity";
description = "More information about the Fediversity project";
summary = ''
The Fediversity Project is a comprehensive effort to bring easy-to-use, hosted cloud services that have service portability and personal freedom at their core to everyone.
'';
outPath = "fediversity.html";
body = ''
# ${title}
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 scenarios where consistent behaviour, stability and configurability matter.
One such complex deployment scenario is running state-of-the-art services for the Fediverse, like PeerTube, Mastodon, Owncast or Lemmy especially if you want to for instance add services like live chat or transcoding. But even running more traditional services like modern e-mail servers with possible whistles and bells can be daunting. The same holds for deploying a VPN, private cloud storage, wiki, etc. Fediversity will enable all of these use cases, and more finally bringing these to the market in a way that is as conveient as using a hosted service.
Fediversity is a pilot funded by the European Commission, building on many projects funding through the Next Generation Internet initiative. The results of the project should greatly simplify the creation and delivery of robust and secure services, on the web and beyond.
Fediversity will deliver an ambitious development effort, but this is a vast domain with many more challenges than what any preconceived effort could tackle by itself. This is why we invite your contribution to help us reshape the state of play, and together create an open, trustworthy and reliable internet for all.
'';
}

17
content/grants.nix Normal file
View file

@ -0,0 +1,17 @@
{
title = "Grants";
description = "How to apply for grants as part of the Fediversity Project";
summary = ''
Fediversity will award 450 000 euro in small to medium-size R&D grants towards solutions that bring the next generation of social networks closer. We are seeking project proposals between 5.000 and 50.000 euros which should get you on your way.
'';
outPath = "grants.html";
body = ''
Fediversity invites other people to join this ambitious development effort. It is a vast domain with many more challenges than what any preconceived effort could tackle by itself. This is why we invite your contribution to help us reshape the state of play, and together create an open, trustworthy and reliable internet for all.
This is your opportunity to make a real difference. You tell us how your project can help Fediversity go harder, better, faster, stronger. In order to enable you to make such contributions, NLnet will award 450 000 euro in small to medium-size R&D grants towards solutions that bring the next generation of social networks closer. NLnet is seeking project proposals between 5.000 and 50.000 euros which should get you on your way.
Noteworthy fact: many projects which are to be deployed inside Fediversity were themselves bootstrapped on precisely such a grant from NGI, and now it is your turn.
For more information on how to apply, check the NLnet website.
'';
}

22
content/index.nix Normal file
View file

@ -0,0 +1,22 @@
let
grants = import ./grants.nix;
fediversity = import ./fediversity.nix;
in
{
title = "Fediversity";
description = "NGI Zero Fediversity";
outPath = "index.html";
body = ''
# Welcome to the Fediversity project
${fediversity.summary}
[Learn more about Fediversity](./${fediversity})
# Fediversity grants
${grants.summary}
[Learn more about our grants](./${grants})
'';
}

View file

@ -2,7 +2,7 @@
# Banner
banner:
title: "Welcome to the Fediversity Project"
content: "The Fediversity Project is a comprehensive effort to bring easy-to-use, hosted cloud services that have service portability and personal freedom at their core to everyone."
content: ""
# image: "/images/checkbox-illustration-scaled.png"
image: "/images/home.svg"
button:
@ -55,7 +55,7 @@ features3:
features:
- title: "Fediversity Grants"
image: "/images/stepping-up.png"
content: "Fediversity will award 450 000 euro in small to medium-size R&D grants towards solutions that bring the next generation of social networks closer. We are seeking project proposals between 5.000 and 50.000 euros — which should get you on your way."
content: ""
button:
enable: true
label: "Learn more"

View file

@ -0,0 +1,17 @@
{
meta = {
title = "Grants";
description = "How to apply for grants as part of the Fediversity Project";
};
body = ''
Fediversity invites other people to join this ambitious development effort. It is a vast domain with many more challenges than what any preconceived effort could tackle by itself. This is why we invite your contribution to help us reshape the state of play, and together create an open, trustworthy and reliable internet for all.
This is your opportunity to make a real difference. You tell us how your project can help Fediversity go harder, better, faster, stronger. In order to enable you to make such contributions, NLnet will award 450 000 euro in small to medium-size R&D grants towards solutions that bring the next generation of social networks closer. NLnet is seeking project proposals between 5.000 and 50.000 euros — which should get you on your way.
Noteworthy fact: many projects which are to be deployed inside Fediversity were themselves bootstrapped on precisely such a grant from NGI, and now it is your turn.
For more information on how to apply, check the NLnet website.
'';
}
---

36
default.nix Normal file
View file

@ -0,0 +1,36 @@
{ sources ? import ./npins
, system ? builtins.currentSystem
, pkgs ? import sources.nixpkgs {
inherit system;
config = { };
overlays = [ ];
}
, lib ? import "${sources.nixpkgs}/lib"
,
}:
let
lib' = pkgs.callPackage ./lib.nix { };
join = lib.concatStringsSep;
in
{
site = pkgs.stdenv.mkDerivation {
name = "fediversity.eu";
src = ./content;
buildPhase = ''
true
'';
installPhase = ''
mkdir $out
'' + join "\n" (lib.mapAttrsToList
(name: value: ''
cp ${value} $out/${name}
'')
(lib'.files ./content));
};
shell = pkgs.mkShellNoCC {
packages = with pkgs; [
cmark
npins
];
};
}

18
lib.nix Normal file
View file

@ -0,0 +1,18 @@
{ pkgs, lib, ... }:
{
files = dir: lib.mapAttrs'
(
name: value:
let
html = "${lib.removeSuffix ".nix" name}.html";
md = "${lib.removeSuffix ".nix" name}.md";
in
{
name = html;
value = pkgs.runCommand html { buildInputs = with pkgs; [ cmark ]; } ''
cmark ${builtins.toFile md (import "${dir}/${name}").body} > $out
'';
}
)
(builtins.readDir dir);
}

80
npins/default.nix Normal file
View file

@ -0,0 +1,80 @@
# Generated by npins. Do not modify; will be overwritten regularly
let
data = builtins.fromJSON (builtins.readFile ./sources.json);
version = data.version;
mkSource =
spec:
assert spec ? type;
let
path =
if spec.type == "Git" then
mkGitSource spec
else if spec.type == "GitRelease" then
mkGitSource spec
else if spec.type == "PyPi" then
mkPyPiSource spec
else if spec.type == "Channel" then
mkChannelSource spec
else
builtins.throw "Unknown source type ${spec.type}";
in
spec // { outPath = path; };
mkGitSource =
{
repository,
revision,
url ? null,
hash,
branch ? null,
...
}:
assert repository ? type;
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
# In the latter case, there we will always be an url to the tarball
if url != null then
(builtins.fetchTarball {
inherit url;
sha256 = hash; # FIXME: check nix version & use SRI hashes
})
else
assert repository.type == "Git";
let
urlToName =
url: rev:
let
matched = builtins.match "^.*/([^/]*)(\\.git)?$" repository.url;
short = builtins.substring 0 7 rev;
appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else "";
in
"${if matched == null then "source" else builtins.head matched}${appendShort}";
name = urlToName repository.url revision;
in
builtins.fetchGit {
url = repository.url;
rev = revision;
inherit name;
# hash = hash;
};
mkPyPiSource =
{ url, hash, ... }:
builtins.fetchurl {
inherit url;
sha256 = hash;
};
mkChannelSource =
{ url, hash, ... }:
builtins.fetchTarball {
inherit url;
sha256 = hash;
};
in
if version == 3 then
builtins.mapAttrs (_: mkSource) data.pins
else
throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"

11
npins/sources.json Normal file
View file

@ -0,0 +1,11 @@
{
"pins": {
"nixpkgs": {
"type": "Channel",
"name": "nixpkgs-unstable",
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-24.11pre691017.b69de56fac8c/nixexprs.tar.xz",
"hash": "0z32pj0lh5ng2a6cn0qfmka8cynnygckn5615mkaxq2aplkvgzx3"
}
},
"version": 3
}

1
shell.nix Normal file
View file

@ -0,0 +1 @@
(import ./. { }).shell