Use Nix function to perform replacement

This commit is contained in:
Danila Fedorin 2022-05-01 20:12:41 +00:00
parent 0f22123471
commit 1c0c7355c1
3 changed files with 8 additions and 10 deletions

View File

@ -5,7 +5,7 @@ cp -r $src/* .
# Hugo can't set baseUrl via CLI for multi-lingual hosts.
# We have to manually edit the configuration.
sed -i "$urlSub" config.toml
patchPhase
# Build site with Hugo
hugo $extraFlags

View File

@ -3,11 +3,11 @@
"blog-source": {
"flake": false,
"locked": {
"lastModified": 1649577215,
"narHash": "sha256-8TqSSEoRwlqCbBpombBCPDlzbiF9OPopdx0o4spFbAU=",
"lastModified": 1651357493,
"narHash": "sha256-F5llZ7YygjVZTkDQ3jOMrqnEFZ8zfK9z3hniEtguyG0=",
"ref": "master",
"rev": "fe1c05fe46336ab43402c863dbba49851cd63c08",
"revCount": 567,
"rev": "2474804258bc892a7d0ba53745ac25fea878a5a6",
"revCount": 578,
"submodules": true,
"type": "git",
"url": "https://dev.danilafe.com/Web-Projects/blog-static.git"

View File

@ -7,11 +7,9 @@ let
inherit (settings) src ssl host;
name = "blog-static";
version = settings.src.rev;
urlSub =
let
regexEscape = lib.escape [ "/" "(" ")" "[" "]" "+" "*" "\\" ];
in
with settings.replaceUrl; "s/${regexEscape from}/${regexEscape to}/g";
postPatch = with settings.replaceUrl; ''
substituteInPlace config.toml --replace ${from} ${to}
'';
publicPath = settings.path;
extraFlags = (if settings.drafts then " -D " else "") + settings.extraFlags;
builder = ./build/builder.sh;