1
0
nixfiles/pkgs/wetter/default.nix

84 lines
1.7 KiB
Nix

{
pkgs,
buildPythonPackage,
flask,
flask_sqlalchemy,
lib,
libsass,
yarn2nix-moretea,
nodejs,
pkg-config,
psycopg2,
python3,
stdenv,
flask-excel,
pyexcel-xlsx,
}:
let
src = pkgs.fetchgit {
url = "https://git.clerie.de/clerie/wetter.git";
rev = "3193c6d507af5d6f5d62c23046b7fbf0c638ddb4";
sha256 = "sha256-ouUmmw020jKg/SRlYhGBFRw/atxW+atQ1JSTFQNi5iw=";
};
pname = "wetter";
version = "0.0.1";
packageJSON = src + "/package.json";
yarnLock = src + "/yarn.lock";
modules = yarn2nix-moretea.mkYarnModules {
pname = "${pname}-modules";
name = "${pname}-modules-${version}";
inherit version packageJSON yarnLock;
/* build native node-sass extensions */
pkgConfig.node-sass = {
buildInputs = [ python3 libsass pkg-config ];
postInstall = ''
export npm_config_nodedir=${nodejs}
LIBSASS_EXT=auto yarn --offline run build
rm build/config.gypi
'';
};
};
assets = stdenv.mkDerivation {
inherit src pname version;
NODE_ENV = "production";
buildPhase = ''
runHook preBuild
ln -s ${modules}/node_modules
node_modules/.bin/rollup -c
runHook postBuild
'';
installPhase = ''
runHook preInstall
cp -r wetter/static/bundle $out
runHook postInstall
'';
};
in buildPythonPackage rec {
inherit src pname version;
propagatedBuildInputs = [
flask
flask_sqlalchemy
psycopg2
flask-excel
pyexcel-xlsx
];
postInstall = ''
mkdir -p $out/${python3.sitePackages}/wetter/static
cp -r ${assets} $out/${python3.sitePackages}/wetter/static/bundle
cp -r wetter/templates $out/${python3.sitePackages}/wetter/templates
'';
doCheck = false;
}