diff options
Diffstat (limited to 'package.nix')
| -rw-r--r-- | package.nix | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/package.nix b/package.nix new file mode 100644 index 00000000..08510aa7 --- /dev/null +++ b/package.nix @@ -0,0 +1,97 @@ +{ + stdenvNoCC, + runCommandNoCC, + util-linux, + moreutils, + parallel, + openssl, + libxml2, + zopfli, + brotli, + rsync, + yajl, + stylelint, + jre, + python3, + buildNpmPackage, +}: +stdenvNoCC.mkDerivation rec { + pname = "hakurei.app"; + version = "0.0.2"; + + src = ./.; + + nodejsEnv = buildNpmPackage { + pname = "grapheneos-nodejs"; + inherit version; + src = builtins.path { + name = "${pname}-nodejs"; + path = ./.; + filter = + path: _: + builtins.elem (/. + path) [ + ./package.json + ./package-lock.json + ]; + }; + dontNpmBuild = true; + npmFlags = [ "--ignore-scripts" ]; + npmDepsHash = "sha256-N3ouirw0B1JtH171/vkA8xtsaQzWnk8+XI2OLaMLeCw="; + }; + + nativeBuildInputs = [ + util-linux + (runCommandNoCC "sponge" { } "mkdir -p $out/bin && ln -s ${moreutils}/bin/sponge $out/bin") + parallel + openssl + libxml2 + zopfli + brotli + rsync + yajl + stylelint + ]; + + buildInputs = [ + jre + (python3.withPackages ( + packages: with packages; [ + lxml + cssselect + + jinja2 + ] + )) + ]; + + configurePhase = '' + runHook preConfigure + + ln -s ${nodejsEnv}/lib/node_modules/${nodejsEnv.pname}/node_modules + + runHook postConfigure + ''; + + buildPhase = '' + runHook preBuild + + sh -x process-static + + rsync -rpcv --chmod=D755,F644 --delete --fsync --preallocate static-tmp/ static-production + python3 generate-sitemap.py + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + xmllint --noblanks static-tmp/sitemap.xml --output static-tmp/sitemap.xml + brotli -f static-tmp/sitemap.xml + zopfli static-tmp/sitemap.xml + rsync -pcv --chmod=D755,F644 --fsync --preallocate static-tmp/sitemap.xml{,.gz,.br} $out + rsync -rptcv --chmod=D755,F644 --delete --fsync --preallocate static-production/ $out + + runHook postInstall + ''; +} |
