From 1c0c7355c18f1c897690b7689256128501831add Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sun, 1 May 2022 20:12:41 +0000 Subject: [PATCH] Use Nix function to perform replacement --- build/builder.sh | 2 +- flake.lock | 8 ++++---- lib.nix | 8 +++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/build/builder.sh b/build/builder.sh index 231f534..fb551e8 100644 --- a/build/builder.sh +++ b/build/builder.sh @@ -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 diff --git a/flake.lock b/flake.lock index 69b736d..e45b092 100644 --- a/flake.lock +++ b/flake.lock @@ -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" diff --git a/lib.nix b/lib.nix index cd0844c..681bdf0 100644 --- a/lib.nix +++ b/lib.nix @@ -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;