treewide: build via nix
This commit is contained in:
97
package.nix
Normal file
97
package.nix
Normal file
@@ -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
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user