This is a follow up on my previous gemlog where I described my setup of `gemserv` on NixOS.
2020-06-04 My Server Setup with NixOS
The other day int 80h reached out to me to let me know that Cargo.lock is now part of the repository. I took this as an opportunity to upgrade to the latest version of `gemserv`. Unfortunately I couldn't completely avoid patching.
First my updated derivation:
gemserv = pkgs.rustPlatform.buildRustPackage rec { name = "gemserv"; src = pkgs.fetchgit { url = "git://80h.dev/gemserv.git"; rev = "cb4ee956200c4de5e02f516fb0198188c12f5551"; sha256 = "1kpmp99fjhkzdy8wd64jk1gpv471m92lpv0bn49xkn6nxkn8mp51"; }; cargoSha256 = "0p6pcinyh9iya9g2rmkjn4kms3scy8w4np8njjc4ynbrwzmzil31"; buildInputs = with pkgs; [ pkg-config openssl ]; patches = [ ./cfg-inside-if.patch ]; };
I also removed the the Let's Encrypt setup and moved the certificates to a fixed location. My plan is to switch to a self signed certificate as soon as the old one expires. There is currently a still ongoing debate about best practices. I will see what I have to do when it's time to update. My configuration now looks like this:
gemserv_conf = pkgs.writeText "config.toml" '' port = 1965 host = "::" log = "info" [[server]] hostname = "otrn.org" dir = "/var/gemini" cert = "/var/lib/secrets/otrn.org/fullchain.pem" key = "/var/lib/secrets/otrn.org/key.pem" index = "index.gmi" cgi = true usrdir = false '';
When building this configuration I got "attributes are not yet allowed on `if` expressions" errors. I suspect that the rust compiler in NixOS stable (rustc-1.43.0) is not recent enough. The attribute in question is concerns the presence of the cgi option. Since I want to use cgi anyway I just removed the annotation. Hence, the patch is:
diff --git a/src/main.rs b/src/main.rs index 995ef13..2721cbb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -290,7 +290,6 @@ async fn handle_connection( if !path.exists() { // See if it's a subpath of a CGI script before returning NotFound - #[cfg(feature = "cgi")] if handle_cgi(&mut con, srv, &request, &url, &path).await? { return Ok(()); } @@ -329,7 +328,6 @@ async fn handle_connection( } } - #[cfg(feature = "cgi")] if handle_cgi(&mut con, srv, &request, &url, &path).await? { return Ok(()); }
An alternative would be to use some overlay to get the latest rust compiler, but I'm not a big fan of adding third party repositories.
I'm reachable at 'gemini@otrn.org'.