From 7931784b3a77e46542d7692a914b89fd294247b2 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 28 Sep 2018 13:34:43 +0200 Subject: Decouple static site generation from system config Updating various hashes and regenerating the whole system config for each content update doesn't feel quite right. Instead nginx now serves Nix store links placed in the home directory of a separte `public` user.This user maintains local clones of page source repositories and generates them using their respective Nix expressions. This allows for greater flexibility while maintaining most of the benefits of declarative configuration. Re-building static site derivations may also be automated using e.g. post-receive hooks. --- host/software/server/website.nix | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 host/software/server/website.nix (limited to 'host/software/server/website.nix') diff --git a/host/software/server/website.nix b/host/software/server/website.nix new file mode 100644 index 0000000..d518d3a --- /dev/null +++ b/host/software/server/website.nix @@ -0,0 +1,29 @@ +{ pkgs, ... }: + +{ + users.extraUsers.public = { + isNormalUser = true; + uid = 2000; + shell = pkgs.fish; + home = "/home/public"; + }; + + # `public` generates websites using their custom derivations via `nix-build` + services.nginx.virtualHosts = let + default = locations: { + inherit locations; + addSSL = true; + enableACME = true; + }; + website = sub: default { + "/".root = "/home/public/${sub}/result"; + }; + in { + "blog.kummerlaender.eu" = website "blog"; + "tree.kummerlaender.eu" = website "tree"; + "pkgs.kummerlaender.eu" = default { + "/".root = "/home/public/pkgs/result"; + "/nixexprs.tar.gz".proxyPass = "http://localhost:3000/adrian/pkgs/archive/master.tar.gz"; + }; + }; +} -- cgit v1.2.3