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.
---
.../blog.kummerlaender.eu-change-domain.patch | 12 -----
host/software/blog.kummerlaender.eu.nix | 20 ---------
host/software/code.kummerlaender.eu.nix | 42 ------------------
host/software/pkgs.kummerlaender.eu.nix | 51 ----------------------
host/software/server/git.nix | 38 ++++++++++++++++
host/software/server/website.nix | 29 ++++++++++++
host/software/tree.kummerlaender.eu.nix | 19 --------
7 files changed, 67 insertions(+), 144 deletions(-)
delete mode 100644 host/software/asset/blog.kummerlaender.eu-change-domain.patch
delete mode 100644 host/software/blog.kummerlaender.eu.nix
delete mode 100644 host/software/code.kummerlaender.eu.nix
delete mode 100644 host/software/pkgs.kummerlaender.eu.nix
create mode 100644 host/software/server/git.nix
create mode 100644 host/software/server/website.nix
delete mode 100644 host/software/tree.kummerlaender.eu.nix
(limited to 'host/software')
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 @@
-
/home/adrian
- Adrian Kummerländer
- Adrian Kummerländer's blog on software development, linux and open source
-- http://localhost:8080
-+ https://blog.kummerlaender.eu
-
-
-
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/code.kummerlaender.eu.nix b/host/software/code.kummerlaender.eu.nix
deleted file mode 100644
index b2507e4..0000000
--- a/host/software/code.kummerlaender.eu.nix
+++ /dev/null
@@ -1,42 +0,0 @@
-{ pkgs, ... }:
-
-{
- services = {
- gitea = {
- enable = true;
- database.type = "sqlite3";
-
- appName = "~/projects";
- domain = "code.kummerlaender.eu";
- rootUrl = "https://code.kummerlaender.eu/";
- httpPort = 3000;
-
- extraConfig = ''
- [server]
- LANDING_PAGE = "explore"
- [service]
- DISABLE_REGISTRATION = true
- SHOW_REGISTRATION_BUTTON = false
- [other]
- SHOW_FOOTER_VERSION = false
- SHOW_FOOTER_TEMPLATE_LOAD_TIME = false
- [api]
- ENABLE_SWAGGER_ENDPOINT = false
- [picture]
- DISABLE_GRAVATAR = true
- [indexer]
- REPO_INDEXER_ENABLED = true
- '';
- };
-
- nginx.virtualHosts."code.kummerlaender.eu" = {
- addSSL = true;
- enableACME = true;
- locations = {
- "/" = {
- proxyPass = "http://localhost:3000/";
- };
- };
- };
- };
-}
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/server/git.nix b/host/software/server/git.nix
new file mode 100644
index 0000000..4eedb53
--- /dev/null
+++ b/host/software/server/git.nix
@@ -0,0 +1,38 @@
+{ pkgs, ... }:
+
+{
+ services = {
+ gitea = {
+ enable = true;
+ database.type = "sqlite3";
+
+ appName = "~/projects";
+ domain = "code.kummerlaender.eu";
+ rootUrl = "https://code.kummerlaender.eu/";
+ httpPort = 3000;
+
+ extraConfig = ''
+ [server]
+ LANDING_PAGE = "explore"
+ [service]
+ DISABLE_REGISTRATION = true
+ SHOW_REGISTRATION_BUTTON = false
+ [other]
+ SHOW_FOOTER_VERSION = false
+ SHOW_FOOTER_TEMPLATE_LOAD_TIME = false
+ [api]
+ ENABLE_SWAGGER_ENDPOINT = false
+ [picture]
+ DISABLE_GRAVATAR = true
+ [indexer]
+ REPO_INDEXER_ENABLED = true
+ '';
+ };
+
+ nginx.virtualHosts."code.kummerlaender.eu" = {
+ addSSL = true;
+ enableACME = true;
+ 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}";
- };
- };
- };
-}
--
cgit v1.2.3