From c9b9430d4faa941a100826945b58347ee70e4e44 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Sat, 10 Jun 2023 12:26:19 -0700 Subject: [PATCH] Make build script NixOS-compatible --- build.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 84560f3..626342d 100755 --- a/build.sh +++ b/build.sh @@ -1,3 +1,12 @@ -#!/bin/bash -hugo -#find public -name '*.html' -type f -exec tidy --quiet yes --drop-empty-elements no --hide-comments yes -mq '{}' \; &> /dev/null +#!/usr/bin/env bash +SCRIPT_DIR=`dirname "$0"` +if command -v nix-shell &> /dev/null; then + # If in NixOS use shell.nix + nix-shell --pure $SCRIPT_DIR/shell.nix --run "cd $SCRIPT_DIR && hugo" +else + # Otherwise use global hugo + DIR=$PWD + cd $SCRIPT_DIR + hugo + cd $DIR +fi