Browse Source

Use Nix function to perform replacement

master
Danila Fedorin 7 months ago
parent
commit
1c0c7355c1
  1. 2
      build/builder.sh
  2. 8
      flake.lock
  3. 8
      lib.nix

2
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

8
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"

8
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;

Loading…
Cancel
Save