diff options
| -rw-r--r-- | default.nix | 174 | ||||
| -rw-r--r-- | html/research/talks.nix | 2 | ||||
| -rw-r--r-- | html/research/writings.nix | 2 |
3 files changed, 110 insertions, 68 deletions
diff --git a/default.nix b/default.nix index 9b507e5..00cd9e7 100644 --- a/default.nix +++ b/default.nix @@ -1,20 +1,25 @@ { stdenvNoCC, # Packages + imagemagick, + jq, line-awesome, line-awesome-css, + minify, + nix, + pandoc, uncss, yuicompressor, - imagemagick, - nix, - minify, # Source files nixpkgsSrc, src, data, # Parameters theme ? "personal-dark", -}: let +}: +let + convert = "${pandoc}/bin/pandoc"; + parseJSON = "${jq}/bin/jq"; compress = "${yuicompressor}/bin/yuicompressor"; clean = "${uncss}/bin/uncss"; compressJPEG = size: image: '' @@ -32,70 +37,107 @@ nixEvalExpr = "${nix}/bin/nix --extra-experimental-features nix-command --extra-experimental-features flakes eval --impure --raw --show-trace --expr"; make = "import $src/make.nix {pkgs = import ${nixpkgsSrc} {}; dataSrc = $src/data;}"; in - stdenvNoCC.mkDerivation { - name = "webpage"; - requiredSystemFeatures = ["recursive-nix"]; - subsrcs = [src data]; - src = "webpage-src"; - unpackPhase = '' - read -ra srcs <<< "$subsrcs" - mkdir $src - ln -s ''${srcs[0]}/* $src/ - ln -s ''${srcs[1]} $src/data - ls $src - ''; - installPhase = '' - # set -o xtrace - pushd $src - src=$(pwd) - popd - ${mkPushDir "$out"} # $out/ +stdenvNoCC.mkDerivation { + name = "webpage"; + extra-sandbox-paths = [ + "/nix/store/" + "/nix/var/nix/" + ]; + subsrcs = [ + src + data + ]; + src = "webpage-src"; + unpackPhase = '' + read -ra srcs <<< "$subsrcs" + mkdir $src + ln -s ''${srcs[0]}/* $src/ + mkdir $src/data + ln -s ''${srcs[1]}/* $src/data/ + rm $src/data/files + mkdir $src/data/files + ln -s ''${srcs[1]}/files/* $src/data/files/ - # build HTML - ${nixEvalExpr} " - ${make} $src/html {} - " > index.html - ${minify}/bin/minify index.html --output index.html + # burst bibliography into src files + pushd $src + src=$(pwd) + popd + pushd $src/data/files/ + chmod u+w . + mkdir -p biblio/{biblatex,bibtex,csljson} + pushd biblio/ + for refs in $src/data/research/*.json + do + ${parseJSON} --compact-output ".[]" $refs | while read -r ref + do + id=$(echo "$ref" | ${parseJSON} --raw-output '.id') + echo $id + echo "$ref" > "csljson/$id" + cat csljson/$id + ${convert} --from=csljson --to=biblatex --output "biblatex/$id" <<< "[ $ref ]" + ${convert} --from=csljson --to=bibtex --output "bibtex/$id" <<< "[ $ref ]" + done + done + popd + chmod -R u-w . + popd - # copy static files - cp -r $src/static/ . - ln -s static/robots.txt - chmod 777 static - pushd static # $out/static/ - cp -r ${data}/files . - chmod 777 files - pushd files # $out/static/files/ - ${compressJPEG "128" "avatar.jpg"} - ${compressJPEG "256" "avatar.jpg"} - ${compressJPEG "512" "avatar.jpg"} + ''; + installPhase = '' + export NIX_STATE_DIR=$TMPDIR/state + export NIX_STORE_DIR=$TMPDIR/state + + # set -o xtrace + pushd $src + src=$(pwd) + popd + ${mkPushDir "$out"} # $out/ + + # build HTML + ${nixEvalExpr} " + ${make} $src/html {} + " > index.html + ${minify}/bin/minify index.html --output index.html - popd # $out/static/ + # copy static files + cp -r $src/static/ . + ln -s static/robots.txt + chmod 777 static + pushd static # $out/static/ + cp -r ${data}/files . + chmod 777 files + pushd files # $out/static/files/ + ${compressJPEG "128" "avatar.jpg"} + ${compressJPEG "256" "avatar.jpg"} + ${compressJPEG "512" "avatar.jpg"} - # build and compress CSS - ${mkPushDir "css"} # $out/static/css/ - ${nixEvalExpr} " - ${make} $src/css/classless.nix ({ - big-first-letter = true; - details-cards = true; - grid = true; - hr = false; - navbar = true; - tables = false; - tooltip-citations = true; - printing = true; - tabs = true; - } // (import $src/css/themes.nix).${theme}) - " > classless.css - ${clean} $out/index.html --stylesheets file://$(pwd)/classless.css \ - | ${compress} --type css >classless.min.css - rm classless.css - ${mkPushDir "fonts/line-awesome"} # $out/static/css/fonts/lineawesome - ln -s ${line-awesome}/share/fonts/woff2 webfonts - ${clean} $out/index.html --stylesheets file://${line-awesome-css} \ - | ${compress} --type css >line-awesome.min.css + popd # $out/static/ - popd # $out/static - popd # $out/ - popd # - ''; - } + # build and compress CSS + ${mkPushDir "css"} # $out/static/css/ + ${nixEvalExpr} " + ${make} $src/css/classless.nix ({ + big-first-letter = true; + details-cards = true; + grid = true; + hr = false; + navbar = true; + tables = false; + tooltip-citations = true; + printing = true; + tabs = true; + } // (import $src/css/themes.nix).${theme}) + " > classless.css + ${clean} $out/index.html --stylesheets file://$(pwd)/classless.css \ + | ${compress} --type css >classless.min.css + rm classless.css + ${mkPushDir "fonts/line-awesome"} # $out/static/css/fonts/lineawesome + ln -s ${line-awesome}/share/fonts/woff2 webfonts + ${clean} $out/index.html --stylesheets file://${line-awesome-css} \ + | ${compress} --type css >line-awesome.min.css + + popd # $out/static + popd # $out/ + popd # + ''; +} diff --git a/html/research/talks.nix b/html/research/talks.nix index a68e9f3..ed2005a 100644 --- a/html/research/talks.nix +++ b/html/research/talks.nix @@ -65,7 +65,7 @@ dl ( title: type: details [ (summary title) - (pre (code (lib.readFile "${data.research.files}/${type}/${id}"))) + (pre (code (lib.readFile "${data.files}/biblio/${type}/${id}"))) ]; in dd [ diff --git a/html/research/writings.nix b/html/research/writings.nix index 205bcf6..c226396 100644 --- a/html/research/writings.nix +++ b/html/research/writings.nix @@ -76,7 +76,7 @@ let title: type: details [ (summary title) - (pre (code (lib.readFile "${data.research.files}/${type}/${id}"))) + (pre (code (lib.readFile "${data.files}/biblio/${type}/${id}"))) ]; in dd [ |
