summaryrefslogtreecommitdiff
path: root/host/software
diff options
context:
space:
mode:
authorAdrian Kummerlaender2018-09-28 13:34:43 +0200
committerAdrian Kummerlaender2018-09-28 13:34:43 +0200
commit7931784b3a77e46542d7692a914b89fd294247b2 (patch)
treefbbdd2ef1c91bc843db111fc591c4a8486963186 /host/software
parent654548a491c8558f7643b853752654db4b6e9cc3 (diff)
downloadnixos_system-7931784b3a77e46542d7692a914b89fd294247b2.tar
nixos_system-7931784b3a77e46542d7692a914b89fd294247b2.tar.gz
nixos_system-7931784b3a77e46542d7692a914b89fd294247b2.tar.bz2
nixos_system-7931784b3a77e46542d7692a914b89fd294247b2.tar.lz
nixos_system-7931784b3a77e46542d7692a914b89fd294247b2.tar.xz
nixos_system-7931784b3a77e46542d7692a914b89fd294247b2.tar.zst
nixos_system-7931784b3a77e46542d7692a914b89fd294247b2.zip
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.
Diffstat (limited to 'host/software')
-rw-r--r--host/software/asset/blog.kummerlaender.eu-change-domain.patch12
-rw-r--r--host/software/blog.kummerlaender.eu.nix20
-rw-r--r--host/software/pkgs.kummerlaender.eu.nix51
-rw-r--r--host/software/server/git.nix (renamed from host/software/code.kummerlaender.eu.nix)8
-rw-r--r--host/software/server/website.nix29
-rw-r--r--host/software/tree.kummerlaender.eu.nix19
6 files changed, 31 insertions, 108 deletions
diff --git a/host/software/asset/blog.kummerlaender.eu-change-domain.patch b/host/software/asset/blog.kummerlaender.eu-change-domain.patch
deleted file mode 100644
index 45d75fd..0000000
--- a/host/software/asset/blog.kummerlaender.eu-change-domain.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff --git a/source/00_content/meta.xml b/source/00_content/meta.xml
---- a/source/00_content/meta.xml
-+++ b/source/00_content/meta.xml
-@@ -3,7 +3,7 @@
- <title>/home/adrian</title>
- <author>Adrian Kummerländer</author>
- <description>Adrian Kummerländer's blog on software development, linux and open source</description>
-- <url>http://localhost:8080</url>
-+ <url>https://blog.kummerlaender.eu</url>
-
- <header>
- <navigation>
diff --git a/host/software/blog.kummerlaender.eu.nix b/host/software/blog.kummerlaender.eu.nix
deleted file mode 100644
index 2328145..0000000
--- a/host/software/blog.kummerlaender.eu.nix
+++ /dev/null
@@ -1,20 +0,0 @@
-{ pkgs, ... }:
-
-let
- result = import (pkgs.fetchFromGitHub {
- owner = "KnairdA";
- repo = "blog_content";
- rev = "c467ca2df2759a00edc4b15f81097299771fcd5c";
- sha256 = "0kinmswnklpvmkaaks7x9gj8yk217299d9rc4ca7kdklmi4xsfrw";
- }) { };
-in {
- services.nginx.virtualHosts."blog.kummerlaender.eu" = {
- addSSL = true;
- enableACME = true;
- locations = {
- "/" = {
- root = "${result}";
- };
- };
- };
-}
diff --git a/host/software/pkgs.kummerlaender.eu.nix b/host/software/pkgs.kummerlaender.eu.nix
deleted file mode 100644
index bc8405f..0000000
--- a/host/software/pkgs.kummerlaender.eu.nix
+++ /dev/null
@@ -1,51 +0,0 @@
-{ pkgs, ... }:
-
-let
- content = pkgs.fetchgit {
- url = "gitea@localhost:adrian/pkgs.git";
- rev = "9e1c4583fd06953db2b2eddf6e183f882b64bd2e";
- sha256 = "0zykfg8z2gmaz3si9n8zhsx7zdxnqn81zg1nr01gi42g85i65zq8";
- };
-
- result = pkgs.stdenv.mkDerivation {
- name = "tree.kummerlaender.eu";
-
- src = pkgs.fetchFromGitHub {
- owner = "KnairdA";
- repo = "tree.kummerlaender.eu";
- rev = "95f100c7ac9fba6116f0e268950b83b706325bf2";
- sha256 = "0llffkjdz3x0yp3nvb1fa6041rj696xnkifvy6kalsbrxy8mbfn5";
- };
-
- LANG = "en_US.UTF-8";
-
- buildInputs = let
- mypkgs = import (fetchTarball "https://pkgs.kummerlaender.eu/nixexprs.tar.gz") { };
- in [
- pkgs.pandoc
- pkgs.highlight
- mypkgs.katex-wrapper
- mypkgs.make-xslt
- ];
-
- installPhase = ''
- cp -r ${content}/web source/00_content
- make-xslt
- mkdir $out
- cp -Lr target/99_result/* $out
- '';
- };
-in {
- services.nginx.virtualHosts."pkgs.kummerlaender.eu" = {
- addSSL = true;
- enableACME = true;
- locations = {
- "/" = {
- root = "${result}";
- };
- "/nixexprs.tar.gz" = {
- proxyPass = "http://localhost:3000/adrian/pkgs/archive/master.tar.gz";
- };
- };
- };
-}
diff --git a/host/software/code.kummerlaender.eu.nix b/host/software/server/git.nix
index b2507e4..4eedb53 100644
--- a/host/software/code.kummerlaender.eu.nix
+++ b/host/software/server/git.nix
@@ -30,13 +30,9 @@
};
nginx.virtualHosts."code.kummerlaender.eu" = {
- addSSL = true;
+ addSSL = true;
enableACME = true;
- locations = {
- "/" = {
- proxyPass = "http://localhost:3000/";
- };
- };
+ locations."/".proxyPass = "http://localhost:3000/";
};
};
}
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";
+ };
+ };
+}
diff --git a/host/software/tree.kummerlaender.eu.nix b/host/software/tree.kummerlaender.eu.nix
deleted file mode 100644
index a4b7fed..0000000
--- a/host/software/tree.kummerlaender.eu.nix
+++ /dev/null
@@ -1,19 +0,0 @@
-{ pkgs, ... }:
-
-let
- result = import (pkgs.fetchgit {
- url = "gitea@localhost:web/tree_content.git";
- rev = "72ebbabe1466d2e7ec3f7b6035bf78dc88bdc35a";
- sha256 = "0dqlqrz8wlgqkrqsn0fk861j81msrprmh7k1q733smgrykmr2v09";
- }) { };
-in {
- services.nginx.virtualHosts."tree.kummerlaender.eu" = {
- addSSL = true;
- enableACME = true;
- locations = {
- "/" = {
- root = "${result}";
- };
- };
- };
-}