First post
Table of Contents
First, there was pages.srht.site
SourceHut is awesome!
Who wouldn't like a completely Open Sourced Software (OSS), self-hostable, free to use, Software Development platform?
The SourceHut software suite contains offerings like:
- Git hosting
- Static page hosting
- And much more (check them out if your curiosity is piqued)!
So, static page hosting? And git hosting of said website source??
Yes.
Following their guide for statically hosting websites, I finally got what I wanted; a not-quite self-hosted blog on a domain(read: FQDN) of my choosing!
Unfortunately...
My big issue, that I struggled with for months, if not a year or more - mainly due to (lack of) interest, was figuring out how to make my domain (read: blog.x10an14.dev) "DNS forward in the background to the correct pages.srht.site".
This was DNS magic I'd never been exposed to before.
Solution!
Before (read: almost a year ago), I'm certain that I was unable to simply set a "simple" CNAME record (pointing to pages.srht.site.). Maybe it was because I previously had other <something else>.x10an14.dev DNS records.
For some reason(tm) it worked fine now (as of this writing).
At some point in the future, I will want to add more subdomains, so maybe I'll have to figure out how to use something like ANAME record.
Results of DNS lookup (now that it works):
; <<>> DiG
;;
;;
;; Then, there was a Nix-powered blog!
So, now I could (manually) use the hut to manually publish (tarballed) static content to x10an14.srht.site/!
So, how would I make this development environment reproducible with Nix?
Well, first we need to make a derivation which tarballs the static content:
# Inside flake.nix:
outputs = {...}@inputs: let
pkgs = import inputs.nixpkgs {inherit system;};
# The build of the tarball
tarball = pkgs.stdenv.mkDerivation {
buildPhase = ''
mkdir -p $out/share
tar -cvz index.html > $out/share/name-self.shortRev or "dirty".tar.gz
'';
name = "blog-tarball";
src = ./.;
};
in {
packages = rec {
build = tarball;
default = build;
};
}
Afterwards, it'd be nice to automate the deployment as much as possible. An issue with Nix, is that no derivation can produce side-effects. So performing things like HTTP requests to send data are by their nature, illegal.
A compromise, could be that we write a script that automates the whole process for us, as if we performed the steps manually:
# Also in the flake.nix:
# Convenience script for upload
uploadBlogScript = pkgs.writeShellApplication {
name = "upload-blog";
runtimeInputs = with pkgs; [hut];
text = ''
declare -a PAGES=(
"blog.x10an14.dev"
"x10an14.srht.site"
)
for site in "''${PAGES[@]}"; do
hut pages publish --domain "''${site}" "tarball/tarballPath"
done
'';
};
in {
packages = rec {
build = tarball;
default = build;
upload = uploadBlogScript;
};
}
Full and complete flake.nix can be found over at sourcehut!
Afterwards Zola saved the day
Finally, a theme/framework is of course required to find the blog readable. Currently, the index.html is very simple, and leaves much to be desired:
<!doctype html>
x10an14's blog
x10an14's blog
Testy.
After dipping a toe into testing out MkDocs blogging, I started searching for other Static Site Generators (SSGs). I didn't particularly like MkDocs blogging framework for their navigation layout, and I wanted search functionality.
Luckily, some searching of the web helped me come across Jamstack's list/overview of SSGs.
After some perusing, I noticed a Rust-powered SSG that piqued my curiosity Zola.
Considering the below tag lines - found on their landing page - I got even more sold on the idea of investing in learning Zola:
- "Easy to use"
- "Everything you need in one binary"
- "No dependencies"
- "Augmented MarkDown"