Allow for multi-host configuration.
This commit is contained in:
parent
05fcf11094
commit
8f8ebe68e0
|
@ -1,12 +1,18 @@
|
||||||
source $stdenv/setup
|
source $stdenv/setup
|
||||||
|
|
||||||
# Build site with Hugo
|
# Copy files to a mutable directory.
|
||||||
cp -r $src/* .
|
cp -r $src/* .
|
||||||
hugo --baseUrl="https://danilafe.com"
|
|
||||||
|
|
||||||
# Render math in HTML and XML files.
|
# Hugo can't set baseUrl via CLI for multi-lingual hosts.
|
||||||
find public/ -regex "public/.*\.html" | xargs ruby $converter
|
# We have to manually edit the configuration.
|
||||||
|
sed -i "$urlSub" config.toml
|
||||||
|
|
||||||
|
# Build site with Hugo
|
||||||
|
hugo $extraFlags
|
||||||
|
|
||||||
# Output result
|
# Output result
|
||||||
mkdir $out
|
mkdir $out
|
||||||
cp -r public/* $out/
|
cp -r public/$publicPath/* $out/
|
||||||
|
|
||||||
|
# Render math in HTML and XML files.
|
||||||
|
find $out/ -regex "$out/.*\.html" | xargs ruby $converter
|
||||||
|
|
|
@ -1,18 +1,58 @@
|
||||||
{ stdenv, hugo, fetchgit, pkgs, nodejs, ruby }:
|
{ stdenv, lib, hugo, fetchgit, pkgs, nodejs, ruby }:
|
||||||
|
|
||||||
let
|
let
|
||||||
url = "https://dev.danilafe.com/Web-Projects/blog-static.git";
|
url = "https://dev.danilafe.com/Web-Projects/blog-static.git";
|
||||||
rev = "3f0df8ae0ddbed1a2a258878e73861b96e4122b0";
|
|
||||||
sha256 = "16xg4d4wkpdc0qynh6jkl6np6x88bdv0aqpkgg4phjq9007nxgjp";
|
|
||||||
requiredPackages = import ./required-packages.nix { inherit pkgs nodejs; };
|
requiredPackages = import ./required-packages.nix { inherit pkgs nodejs; };
|
||||||
in
|
website = settings: stdenv.mkDerivation {
|
||||||
stdenv.mkDerivation {
|
|
||||||
name = "blog-static";
|
name = "blog-static";
|
||||||
version = rev;
|
version = settings.rev;
|
||||||
src = fetchgit {
|
src = fetchgit {
|
||||||
inherit url rev sha256;
|
inherit url;
|
||||||
|
inherit (settings) rev sha256;
|
||||||
};
|
};
|
||||||
|
urlSub =
|
||||||
|
let
|
||||||
|
regexEscape = lib.escape [ "/" "(" ")" "[" "]" "+" "*" "\\" ];
|
||||||
|
in
|
||||||
|
if (settings ? replaceUrl)
|
||||||
|
then (with settings.replaceUrl; "s/${regexEscape from}/${regexEscape to}/g")
|
||||||
|
else "";
|
||||||
|
publicPath = settings.path;
|
||||||
|
extraFlags = if settings.drafts then " -D " else "";
|
||||||
builder = ./builder.sh;
|
builder = ./builder.sh;
|
||||||
converter = ./convert.rb;
|
converter = ./convert.rb;
|
||||||
buildInputs = [ hugo requiredPackages.katex (ruby.withPackages (ps: [ ps.nokogiri ])) ];
|
buildInputs = [ hugo requiredPackages.katex (ruby.withPackages (ps: [ ps.nokogiri ])) ];
|
||||||
|
};
|
||||||
|
rev = "b921ddfc8de1282cc82a0d90b2927bf2a5c0ee68";
|
||||||
|
sha256 = "1gg7dq9y1hg14qjlj2w1rn0xjgqw58s8kpd5x6c0wfpwszcm87ji";
|
||||||
|
localizationRev = "cd574b43fdddf8b6777610f94897d70697533af9";
|
||||||
|
localizationSha256 = "1lv65bllrc605lda5gqgpk4ihhg77qgh1zg60swsllmhh5vawgbn";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
english = website {
|
||||||
|
inherit rev sha256;
|
||||||
|
path = ".";
|
||||||
|
drafts = false;
|
||||||
|
};
|
||||||
|
drafts = {
|
||||||
|
english = website {
|
||||||
|
inherit rev sha256;
|
||||||
|
path = ".";
|
||||||
|
drafts = true;
|
||||||
|
replaceUrl = {
|
||||||
|
from = "https://danilafe.com";
|
||||||
|
to = "http://drafts.danilafe.com";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
russian = website {
|
||||||
|
rev = localizationRev;
|
||||||
|
sha256 = localizationSha256;
|
||||||
|
path = "ru";
|
||||||
|
drafts = true;
|
||||||
|
replaceUrl = {
|
||||||
|
from = "https://ru.danilafe.com";
|
||||||
|
to = "http://drafts.ru.danilafe.com";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue
Block a user