Initial commit

This commit is contained in:
Charlotte Van Petegem 2022-11-04 10:32:25 +01:00
commit 9a5b3e282a
No known key found for this signature in database
GPG key ID: 019E764B7184435A
17 changed files with 490 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/src/public
/result

67
flake.lock generated Normal file
View file

@ -0,0 +1,67 @@
{
"nodes": {
"devshell": {
"inputs": {
"flake-utils": [
"flake-utils"
],
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1667210711,
"narHash": "sha256-IoErjXZAkzYWHEpQqwu/DeRNJGFdR7X2OGbkhMqMrpw=",
"owner": "numtide",
"repo": "devshell",
"rev": "96a9dd12b8a447840cc246e17a47b81a4268bba7",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1667482890,
"narHash": "sha256-pua0jp87iwN7NBY5/ypx0s9L9CG49Ju/NI4wGwurHc4=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "a2a777538d971c6b01c6e54af89ddd6567c055e8",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"devshell": "devshell",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

55
flake.nix Normal file
View file

@ -0,0 +1,55 @@
{
description = "My personal website";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
devshell = {
url = "github:numtide/devshell";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
};
outputs = { self, nixpkgs, devshell, flake-utils }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs { inherit system; overlays = [ devshell.overlay ]; };
pkg = pkgs.stdenv.mkDerivation {
pname = "www.chvp.be";
version = "unstable";
src = ./src;
buildPhase = ''
${pkgs.zola}/bin/zola build
'';
installPhase = ''
cp -r public $out
'';
};
shell = pkgs.devshell.mkShell {
name = "Website";
packages = with pkgs; [
nixpkgs-fmt
zola
];
};
in
{
packages = {
default = pkg;
"www.chvp.be" = pkg;
};
devShells = rec {
default = shell;
"www.chvp.be" = shell;
};
}
) // {
overlay = (curr: prev: {
"www.chvp.be" = self.packages.${curr.system}.default;
});
};
}

31
src/config.toml Normal file
View file

@ -0,0 +1,31 @@
# The URL the site will be built for
base_url = "https://www.chvp.be"
title = "Charlotte Van Petegem's website"
description = "Blog posts and other musings"
# Whether to automatically compile all Sass files in the sass directory
compile_sass = true
# Whether to build a search index to be used later on by a JavaScript library
build_search_index = false
generate_feed = false
taxonomies = [
{ name = "Tags" }
]
[markdown]
# Whether to do syntax highlighting
# Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola
highlight_code = true
highligt_theme = "ayu-dark"
external_links_target_blank = true
external_links_no_follow = true
external_links_no_referrer = true
smart_punctuation = true
[extra]
# Put all your custom variables here

3
src/content/_index.md Normal file
View file

@ -0,0 +1,3 @@
+++
title = "Homepage"
+++

10
src/content/about.md Normal file
View file

@ -0,0 +1,10 @@
+++
title = "About me"
+++
I am a PhD student at Ghent University working on
[Dodona](https://dodona.ugent.be/en). My main side project is
[Accentor](https://github.com/accentor), a self-hosted music server. I am
passionate about NixOS and general open-source development. My hobbies also
include listening to music, going to concerts, reading, and long-distance
running. In the remaining time I volunteer for the Red Cross.

View file

@ -0,0 +1,131 @@
+++
title = "Setting up Nextcloud as a UnifiedPush provider on NixOS"
[taxonomies]
Tags = ["Nix", "NixOS", "Fediverse", "Matrix", "Android"]
+++
I recently set up Nextcloud as a UnifiedPush provider on NixOS. Since others
might want to do the same, I've detailed the process in this blog post. First I
will explain in a nutshell what UnifiedPush is and why anyone would want to use
it, next I will go over the steps required for setting it up.
<!-- more -->
## UnifiedPush
UnifiedPush is used to deliver push notifications to Android devices. It
specifies how servers should talk with push providers, and how apps should talk
with push distributors. The push distributor is the only app keeping open a
connection to the push provider, making this a lot more efficient than every app
that needs push notifications implementing its own polling mechanism. Since
receiving push notifications is the only function of a push distributor, I also
trust it more to do so efficiently. When the push distributor receives a
notification, it distributes it to the corresponding app, which can now react to
the actual notification.
Apps that want to receive push notifications need to register with the push
distributor first. The push distributor will then give the app the information
that the server backend needs to send the push notifications.
Note that nothing about this is Android-specific; one could implement a push
distributor for any sufficiently open platform (in fact, a [D-Bus distributor
specification](https://unifiedpush.org/spec/dbus/) exists). However, since
Android is the most widely-used mobile OS where something like this is possible,
it is the platform where most of the development has happened.
UnifiedPush is a great alternative to Firebase Cloud Messaging (Google's push
notification service). Apps do not need to register with any central authority
and do not need to pay to send push notifications. Users are free to choose
which service their data flows through, and as this post shows, can even
self-host this service. A number of apps already support this service; in my
case I am using [Tusky](https://tusky.app/) (a Mastodon client) and [Element
Android](https://matrix.org/docs/projects/client/element-android/) (a Matrix
client).
## Configuring Nextcloud
### Prerequisites
I assume that you've already set up a Nextcloud instance (using the [NixOS module](https://search.nixos.org/options?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=services.nextcloud.)). The
module is not that complicated if not. Feel free to steal any part of [my config](https://github.com/chvp/nixos-config/blob/main/modules/services/nextcloud/default.nix).
### NixOS configuration
First, you need to make sure that Nextcloud can load the redis PHP module, that
you have a redis server running and that Nextcloud is configured to use it. Redis
is used as a message broker in this case, so if this part is missing the
communication from the notifying servers will not go through to the devices that
are listening. In addition to redis, you also need to tweak nginx to allow the
long-running requests that are typically used for push notifications.
The configuration for Nextcloud should look like this:
```nix
{
services.nextcloud = {
# Your other configuration here
caching.redis = true;
extraOptions.redis = {
host = "127.0.0.1";
port = 31638;
dbindex = 0;
timeout = 1.5;
};
};
}
```
Of course, you need to configure redis as well:
```nix
{
services.redis.servers.nextcloud = {
enable = true;
port = 31638;
bind = "127.0.0.1";
};
}
```
And finally, you need to make sure you allow long-running requests in nginx:
```nix
{
services.nginx.virtualHosts."your.nextcloud.hostname".extraConfig = ''
fastcgi_connect_timeout 10m;
fastcgi_read_timeout 10m;
fastcgi_send_timeout 10m;
'';
}
```
Make sure to switch to the new configuration after making your edits.
### Nextcloud configuration
After setting up Nextcloud itself, you still need to install the ["UnifiedPush
Provider"](https://apps.nextcloud.com/apps/uppush) app. This can be found under
the Multimedia category in the Nextcloud apps admin interface. Note that you can
also manage Nextcloud apps declaratively on NixOS, but I personally don't do so,
so I will not detail the process here.
### Device configuration
To use UnifiedPush on your Android device you need to have both the
[Nextcloud](https://f-droid.org/en/packages/com.nextcloud.client/) and the
[NextPush](https://f-droid.org/en/packages/org.unifiedpush.distributor.nextpush/)
app installed. Opening the NextPush app should guide you through setting it
up. Once you've done that, you can start registering apps with NextPush. For
example, to register Element Android go to the Notifications settings in Element
Android and pick NextPush as your notification method. To set up Tusky, I
haven't found a better way than logging out and back in again.
Once you've followed these steps, you should have a working push notification
setup.
## Conclusion
As you can see, the process for setting up UnifiedPush using Nextcloud is not
that involved. I was personally really impressed with how quickly I was able to
get everything working. It is really nice to see that the open-source and free
software community can implement the niceties that we've come to expect from
modern life without needing a big tech giant to do so.

View file

@ -0,0 +1,6 @@
+++
title = "Posts"
sort_by = "date"
generate_feed = true
page_template = "post.html"
+++

58
src/sass/style.scss Normal file
View file

@ -0,0 +1,58 @@
body {
margin: 0;
}
header {
border-bottom: black 1px solid;
padding: 0.5em;
section {
display: inline;
+ section::before {
content: '| ';
}
}
}
main {
padding: 0.5em;
max-width: 60em;
margin: 0 auto;
}
footer {
border-top: black 1px solid;
padding: 0.5em;
section {
display: inline;
+ section::before {
content: '| ';
}
}
}
pre {
padding: 0.5em;
}
.post-list {
padding: 0;
margin: 0;
li {
list-style-type: none;
}
}
.inline-list {
padding: 0;
margin: 0;
li {
display: inline;
list-style-type: none;
&+ li::before {
content: '/ '
}
}
}

BIN
src/static/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

29
src/templates/base.html Normal file
View file

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{% block title %} {% endblock %} | Charlotte Van Petegem</title>
<link rel="alternate" type="application/atom+xml" title="Atom" href="{{ get_url(path="blog/atom.xml", trailing_slash=false) }}">
<link rel="stylesheet" href="{{ get_url(path="/style.css") }}">
</head>
<body>
<header>
<section>
<a href="{{ get_url(path="@/_index.md" )}}">Homepage</a>
</section>
<section>
<a href="{{ get_url(path="@/blog/_index.md") }}">Blog</a>
</section>
</header>
<main>
{% block content %} {% endblock %}
</main>
<footer>
<section><a href="{{ get_url(path="@/about.md") }}">About me</a></section>
<section><a href="{{ get_url(path="blog/atom.xml", trailing_slash=false) }}">Atom/RSS</a></section>
<section>This website was lovingly crafted using <a href="https://www.getzola.org" target="_blank" rel="noopener nofollow noreferrer">Zola</a>.</section>
</ul>
</footer>
</body>
</html>

23
src/templates/index.html Normal file
View file

@ -0,0 +1,23 @@
{% extends "base.html" %}
{% block title %}{{ section.title }}{% endblock title %}
{% block content %}
<p>
Hi! Welcome to my website. It contains mostly blog posts. The three most recent
blog posts are listed below. Some more info about me is contained in the
appropiately named <a href="{{ get_url(path="@/about.md")}}">About me</a> page.
</p>
<h2>Most recent posts</h2>
{% set blog_section = get_section(path="blog/_index.md") %}
<ul class="post-list">
{% for page in blog_section.pages | slice(end=3) %}
<li>
<p><a href="{{ page.permalink | safe }}">{{ page.title }}</a> ({{ page.date }})</p>
<p>{{ page.summary | safe }}</p>
<p><a href="{{ page.permalink }}#continue-reading">Continue reading&hellip;</a>
</li>
{% endfor %}
</ul>
<a href="{{ get_url(path='@/blog/_index.md') }}">All posts</a>
{% endblock content %}

8
src/templates/page.html Normal file
View file

@ -0,0 +1,8 @@
{% extends "base.html" %}
{% block title %}{{ page.title }}{% endblock %}
{% block content %}
<h1>{{ page.title }}</h1>
{{ page.content | safe }}
{% endblock content %}

15
src/templates/post.html Normal file
View file

@ -0,0 +1,15 @@
{% extends "base.html" %}
{% block title %}{{ page.title }}{% endblock %}
{% block content %}
<h1>{{ page.title }}<br><small>{{ page.date }}</small></h1>
{{ page.content | safe }}
<p>
Comments or questions about this post? Feel free to contact me <a
target="_blank" href="https://social.chvp.be/@chvp">on Mastodon</a> or send
me <a href="mailto:blog@chvp.be?subject={{page.title}}">an email</a>.
</p>
{% endblock content %}

View file

@ -0,0 +1,20 @@
{% extends "base.html" %}
{% block title %}
{{ section.title }}
{% endblock title %}
{% block content %}
<h1>
{{ section.title }}
</h1>
<ul class="post-list">
{% for page in section.pages %}
<li>
<p><a href="{{ page.permalink | safe }}">{{ page.title }}</a> ({{ page.date }})</p>
<p>{{ page.summary | safe }}</p>
<p><a href="{{ page.permalink }}#continue-reading">Continue reading&hellip;</a>
</li>
{% endfor %}
</ul>
{% endblock content %}

View file

@ -0,0 +1,14 @@
{% extends "base.html" %}
{% block title %}{{ taxonomy.name }}{% endblock title %}
{% block content %}
<h1 class="title">
{{ taxonomy.name }}
</h1>
<ul class="inline-list">
{% for term in terms %}
<li><a href="{{ term.permalink }}">{{ term.name}}</a> ({{ term.pages | length }})</li>
{% endfor %}
</ul>
{% endblock content %}

View file

@ -0,0 +1,18 @@
{% extends "base.html" %}
{% block title %}{{ term.name }}{% endblock title %}
{% block content %}
<h1 class="title" >
{{ term.name }}
</h1>
<ul class="post-list">
{% for page in term.pages %}
<li>
<h4><a href="{{ page.permalink | safe }}">{{ page.title }}</a></h4>
<p>{{ page.summary | safe }}</p>
<p><a href="{{ page.permalink }}#continue-reading">Continue reading&hellip;</a>
</li>
{% endfor %}
</ul>
{% endblock content %}