combine blog and djangostatic
This commit is contained in:
19
pkgs/e11sync-blog.nix
Normal file
19
pkgs/e11sync-blog.nix
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
stdenv,
|
||||
dart-sass,
|
||||
hugo,
|
||||
}:
|
||||
stdenv.mkDerivation rec {
|
||||
name = "e11sync-blog";
|
||||
srcs = [../blog ../static];
|
||||
nativeBuildInputs = [dart-sass];
|
||||
sourceRoot = ".";
|
||||
buildPhase = ''
|
||||
cd blog
|
||||
${hugo}/bin/hugo --printPathWarnings --panicOnWarning
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
mv public/{static,blog,contact} $out/
|
||||
'';
|
||||
}
|
||||
@@ -3,19 +3,39 @@
|
||||
zopfli,
|
||||
brotli,
|
||||
findutils,
|
||||
e11sync-blog,
|
||||
e11sync-djangostatic,
|
||||
}:
|
||||
runCommand "e11sync-static" {
|
||||
src = e11sync-djangostatic;
|
||||
srcs = [e11sync-djangostatic e11sync-blog];
|
||||
nativeBuildInputs = [findutils];
|
||||
sourceRoot = ".";
|
||||
} ''
|
||||
unpackPhase
|
||||
find e11sync-djangostatic \
|
||||
|
||||
# check that {e11sync-djangostatic,e11sync-blog/static/style.*.css
|
||||
# is the same file
|
||||
hash1=$(echo e11sync-djangostatic/static/style.*.css | sed 's;.*/;;' )
|
||||
hash2=$(echo e11sync-blog/static/style.*.css | sed 's;.*/;;' )
|
||||
|
||||
if [ "$hash1" != "$hash2" ]; then
|
||||
{
|
||||
echo "style.*.css in blog and django do not match:"
|
||||
ls e11sync-djangostatic/style/style.*.css
|
||||
ls blog/style/style.*.css
|
||||
} >&2
|
||||
fi
|
||||
|
||||
mkdir -p $out
|
||||
mv e11sync-djangostatic/* $out/
|
||||
mv --no-clobber e11sync-blog/{static,blog,contact} $out/
|
||||
|
||||
find $out \
|
||||
-name '*.css' -or \
|
||||
-name '*.js' -or \
|
||||
-name '*.svg' -or \
|
||||
-name '*.html' -or \
|
||||
-name '*.txt' | \
|
||||
tee >(xargs -n1 -P''$(nproc) ${zopfli}/bin/zopfli) | \
|
||||
xargs -n1 -P''$(nproc) ${brotli}/bin/brotli
|
||||
mv e11sync-djangostatic $out
|
||||
''
|
||||
|
||||
Reference in New Issue
Block a user