2019-07-18 13:18:26 +00:00
|
|
|
{ lib
|
2019-07-19 01:09:16 +00:00
|
|
|
, stdenv
|
2021-07-09 08:20:32 +00:00
|
|
|
, python
|
2019-07-18 13:18:26 +00:00
|
|
|
, buildPythonPackage
|
2019-07-19 01:09:16 +00:00
|
|
|
, fetchFromGitHub
|
2019-07-18 13:18:26 +00:00
|
|
|
, alembic
|
2021-07-09 08:20:32 +00:00
|
|
|
, argcomplete
|
|
|
|
, attrs
|
|
|
|
, blinker
|
2019-11-15 21:14:25 +00:00
|
|
|
, cached-property
|
2021-07-09 08:20:32 +00:00
|
|
|
, cattrs
|
|
|
|
, clickclick
|
2019-11-15 21:14:25 +00:00
|
|
|
, colorlog
|
2022-10-02 16:32:23 +00:00
|
|
|
, configupdater
|
2022-08-25 16:57:50 +00:00
|
|
|
, connexion
|
|
|
|
, cron-descriptor
|
2019-07-18 13:18:26 +00:00
|
|
|
, croniter
|
2021-07-09 08:20:32 +00:00
|
|
|
, cryptography
|
2022-08-25 16:57:50 +00:00
|
|
|
, deprecated
|
2019-07-18 13:18:26 +00:00
|
|
|
, dill
|
|
|
|
, flask
|
2022-10-17 18:39:24 +00:00
|
|
|
, flask-login
|
2022-01-12 14:43:09 +00:00
|
|
|
, flask-appbuilder
|
|
|
|
, flask-caching
|
2022-08-25 16:57:50 +00:00
|
|
|
, flask-session
|
|
|
|
, flask-wtf
|
2022-12-05 18:57:29 +00:00
|
|
|
, gitpython
|
2021-07-09 08:20:32 +00:00
|
|
|
, graphviz
|
2019-07-18 13:18:26 +00:00
|
|
|
, gunicorn
|
2021-07-09 08:20:32 +00:00
|
|
|
, httpx
|
2019-07-18 13:18:26 +00:00
|
|
|
, iso8601
|
2021-07-09 08:20:32 +00:00
|
|
|
, importlib-resources
|
|
|
|
, importlib-metadata
|
|
|
|
, inflection
|
|
|
|
, itsdangerous
|
2019-07-18 13:18:26 +00:00
|
|
|
, jinja2
|
2021-07-09 08:20:32 +00:00
|
|
|
, jsonschema
|
2019-11-15 21:14:25 +00:00
|
|
|
, lazy-object-proxy
|
2022-08-25 16:57:50 +00:00
|
|
|
, linkify-it-py
|
2021-07-09 08:20:32 +00:00
|
|
|
, lockfile
|
2019-07-18 13:18:26 +00:00
|
|
|
, markdown
|
2021-07-09 08:20:32 +00:00
|
|
|
, markupsafe
|
|
|
|
, marshmallow-oneofschema
|
2022-08-25 16:57:50 +00:00
|
|
|
, mdit-py-plugins
|
2021-07-09 08:20:32 +00:00
|
|
|
, numpy
|
|
|
|
, openapi-spec-validator
|
2019-07-18 13:18:26 +00:00
|
|
|
, pandas
|
2022-08-25 16:57:50 +00:00
|
|
|
, pathspec
|
2019-07-18 13:18:26 +00:00
|
|
|
, pendulum
|
|
|
|
, psutil
|
|
|
|
, pygments
|
2021-07-09 08:20:32 +00:00
|
|
|
, pyjwt
|
2019-07-18 13:18:26 +00:00
|
|
|
, python-daemon
|
|
|
|
, python-dateutil
|
2021-07-09 08:20:32 +00:00
|
|
|
, python-nvd3
|
|
|
|
, python-slugify
|
|
|
|
, python3-openid
|
2022-01-12 14:43:09 +00:00
|
|
|
, pythonOlder
|
2021-07-09 08:20:32 +00:00
|
|
|
, pyyaml
|
|
|
|
, rich
|
2019-07-18 13:18:26 +00:00
|
|
|
, setproctitle
|
|
|
|
, sqlalchemy
|
2021-07-09 08:20:32 +00:00
|
|
|
, sqlalchemy-jsonfield
|
|
|
|
, swagger-ui-bundle
|
2019-07-18 13:18:26 +00:00
|
|
|
, tabulate
|
|
|
|
, tenacity
|
2019-11-15 21:14:25 +00:00
|
|
|
, termcolor
|
2022-08-25 16:57:50 +00:00
|
|
|
, typing-extensions
|
2019-07-18 13:18:26 +00:00
|
|
|
, unicodecsv
|
2021-07-09 08:20:32 +00:00
|
|
|
, werkzeug
|
2021-11-20 00:33:39 +00:00
|
|
|
, pytestCheckHook
|
2021-07-09 08:20:32 +00:00
|
|
|
, freezegun
|
|
|
|
, mkYarnPackage
|
2022-09-09 13:46:05 +00:00
|
|
|
, writeScript
|
2022-09-09 13:21:29 +00:00
|
|
|
|
|
|
|
# Extra airflow providers to enable
|
|
|
|
, enabledProviders ? []
|
2019-07-18 13:18:26 +00:00
|
|
|
}:
|
2021-07-09 08:20:32 +00:00
|
|
|
let
|
2023-02-27 01:14:05 +00:00
|
|
|
version = "2.5.1";
|
2019-07-18 13:18:26 +00:00
|
|
|
|
2021-07-09 08:20:32 +00:00
|
|
|
airflow-src = fetchFromGitHub rec {
|
2019-07-19 01:09:16 +00:00
|
|
|
owner = "apache";
|
|
|
|
repo = "airflow";
|
2022-07-16 10:58:56 +00:00
|
|
|
rev = "refs/tags/${version}";
|
2022-11-21 16:10:13 +00:00
|
|
|
# Download using the git protocol rather than using tarballs, because the
|
|
|
|
# GitHub archive tarballs don't appear to include tests
|
|
|
|
forceFetchGit = true;
|
2023-02-27 01:14:05 +00:00
|
|
|
hash = "sha256-BuJfE6SONTNonUvacOAIdZe0QicdBtx7k186TJZpQOs=";
|
2019-07-18 13:18:26 +00:00
|
|
|
};
|
|
|
|
|
2021-07-09 08:20:32 +00:00
|
|
|
# airflow bundles a web interface, which is built using webpack by an undocumented shell script in airflow's source tree.
|
|
|
|
# This replicates this shell script, fixing bugs in yarn.lock and package.json
|
|
|
|
|
|
|
|
airflow-frontend = mkYarnPackage {
|
|
|
|
name = "airflow-frontend";
|
|
|
|
|
|
|
|
src = "${airflow-src}/airflow/www";
|
|
|
|
packageJSON = ./package.json;
|
|
|
|
yarnLock = ./yarn.lock;
|
|
|
|
yarnNix = ./yarn.nix;
|
|
|
|
|
|
|
|
distPhase = "true";
|
|
|
|
|
2022-08-25 16:57:50 +00:00
|
|
|
# The webpack license plugin tries to create /licenses when given the
|
|
|
|
# original relative path
|
|
|
|
postPatch = ''
|
|
|
|
sed -i 's!../../../../licenses/LICENSES-ui.txt!licenses/LICENSES-ui.txt!' webpack.config.js
|
|
|
|
'';
|
|
|
|
|
2021-07-09 08:20:32 +00:00
|
|
|
configurePhase = ''
|
|
|
|
cp -r $node_modules node_modules
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
yarn --offline build
|
|
|
|
find package.json yarn.lock static/css static/js -type f | sort | xargs md5sum > static/dist/sum.md5
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/static/
|
|
|
|
cp -r static/dist $out/static
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-09-09 13:21:29 +00:00
|
|
|
# Import generated file with metadata for provider dependencies and imports.
|
|
|
|
# Enable additional providers using enabledProviders above.
|
|
|
|
providers = import ./providers.nix;
|
|
|
|
getProviderDeps = provider: map (dep: python.pkgs.${dep}) providers.${provider}.deps;
|
|
|
|
getProviderImports = provider: providers.${provider}.imports;
|
|
|
|
providerDependencies = lib.concatMap getProviderDeps enabledProviders;
|
|
|
|
providerImports = lib.concatMap getProviderImports enabledProviders;
|
2021-07-09 08:20:32 +00:00
|
|
|
in
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "apache-airflow";
|
|
|
|
inherit version;
|
|
|
|
src = airflow-src;
|
2019-11-15 21:14:25 +00:00
|
|
|
|
2022-11-28 01:26:00 +00:00
|
|
|
disabled = pythonOlder "3.7";
|
2022-01-12 14:43:09 +00:00
|
|
|
|
2019-07-18 13:18:26 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
alembic
|
2021-07-09 08:20:32 +00:00
|
|
|
argcomplete
|
|
|
|
attrs
|
|
|
|
blinker
|
2019-11-15 21:14:25 +00:00
|
|
|
cached-property
|
2021-07-09 08:20:32 +00:00
|
|
|
cattrs
|
|
|
|
clickclick
|
2019-11-15 21:14:25 +00:00
|
|
|
colorlog
|
2022-10-02 16:32:23 +00:00
|
|
|
configupdater
|
2022-08-25 16:57:50 +00:00
|
|
|
connexion
|
|
|
|
cron-descriptor
|
2019-07-18 13:18:26 +00:00
|
|
|
croniter
|
2021-07-09 08:20:32 +00:00
|
|
|
cryptography
|
2022-08-25 16:57:50 +00:00
|
|
|
deprecated
|
2019-07-18 13:18:26 +00:00
|
|
|
dill
|
|
|
|
flask
|
2019-11-15 21:14:25 +00:00
|
|
|
flask-appbuilder
|
2019-07-18 13:18:26 +00:00
|
|
|
flask-caching
|
2022-08-25 16:57:50 +00:00
|
|
|
flask-session
|
2022-05-24 04:09:51 +00:00
|
|
|
flask-wtf
|
2022-10-17 18:39:24 +00:00
|
|
|
flask-login
|
2022-12-05 18:57:29 +00:00
|
|
|
gitpython
|
2021-07-09 08:20:32 +00:00
|
|
|
graphviz
|
2019-07-18 13:18:26 +00:00
|
|
|
gunicorn
|
2021-07-09 08:20:32 +00:00
|
|
|
httpx
|
2019-07-18 13:18:26 +00:00
|
|
|
iso8601
|
2021-07-09 08:20:32 +00:00
|
|
|
importlib-resources
|
|
|
|
inflection
|
|
|
|
itsdangerous
|
2019-07-18 13:18:26 +00:00
|
|
|
jinja2
|
2021-07-09 08:20:32 +00:00
|
|
|
jsonschema
|
2019-11-15 21:14:25 +00:00
|
|
|
lazy-object-proxy
|
2022-08-25 16:57:50 +00:00
|
|
|
linkify-it-py
|
2021-07-09 08:20:32 +00:00
|
|
|
lockfile
|
2019-07-18 13:18:26 +00:00
|
|
|
markdown
|
2021-07-09 08:20:32 +00:00
|
|
|
markupsafe
|
|
|
|
marshmallow-oneofschema
|
2022-08-25 16:57:50 +00:00
|
|
|
mdit-py-plugins
|
2021-07-09 08:20:32 +00:00
|
|
|
numpy
|
|
|
|
openapi-spec-validator
|
2019-07-18 13:18:26 +00:00
|
|
|
pandas
|
2022-08-25 16:57:50 +00:00
|
|
|
pathspec
|
2019-11-15 21:14:25 +00:00
|
|
|
pendulum
|
2019-07-18 13:18:26 +00:00
|
|
|
psutil
|
|
|
|
pygments
|
2021-07-09 08:20:32 +00:00
|
|
|
pyjwt
|
2019-07-18 13:18:26 +00:00
|
|
|
python-daemon
|
|
|
|
python-dateutil
|
2021-07-09 08:20:32 +00:00
|
|
|
python-nvd3
|
|
|
|
python-slugify
|
|
|
|
python3-openid
|
|
|
|
pyyaml
|
|
|
|
rich
|
2019-07-18 13:18:26 +00:00
|
|
|
setproctitle
|
|
|
|
sqlalchemy
|
2021-07-09 08:20:32 +00:00
|
|
|
sqlalchemy-jsonfield
|
|
|
|
swagger-ui-bundle
|
2019-07-18 13:18:26 +00:00
|
|
|
tabulate
|
|
|
|
tenacity
|
2019-11-15 21:14:25 +00:00
|
|
|
termcolor
|
2022-08-25 16:57:50 +00:00
|
|
|
typing-extensions
|
2019-07-18 13:18:26 +00:00
|
|
|
unicodecsv
|
2021-07-09 08:20:32 +00:00
|
|
|
werkzeug
|
2022-01-12 14:43:09 +00:00
|
|
|
] ++ lib.optionals (pythonOlder "3.9") [
|
|
|
|
importlib-metadata
|
2022-09-09 13:21:29 +00:00
|
|
|
] ++ providerDependencies;
|
2021-07-09 08:20:32 +00:00
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
airflow-frontend
|
2019-11-15 21:14:25 +00:00
|
|
|
];
|
2019-07-18 13:18:26 +00:00
|
|
|
|
2023-01-21 12:00:00 +00:00
|
|
|
nativeCheckInputs = [
|
2021-07-09 08:20:32 +00:00
|
|
|
freezegun
|
2021-11-20 00:33:39 +00:00
|
|
|
pytestCheckHook
|
2019-07-18 13:18:26 +00:00
|
|
|
];
|
|
|
|
|
2022-09-09 13:21:29 +00:00
|
|
|
# By default, source code of providers is included but unusable due to missing
|
|
|
|
# transitive dependencies. To enable a provider, add it to extraProviders
|
|
|
|
# above
|
2021-07-09 08:20:32 +00:00
|
|
|
INSTALL_PROVIDERS_FROM_SOURCES = "true";
|
|
|
|
|
2019-07-18 13:18:26 +00:00
|
|
|
postPatch = ''
|
2021-07-09 08:20:32 +00:00
|
|
|
substituteInPlace setup.cfg \
|
2022-08-25 16:57:50 +00:00
|
|
|
--replace "colorlog>=4.0.2, <5.0" "colorlog" \
|
2022-11-21 16:10:13 +00:00
|
|
|
--replace "flask-appbuilder==4.1.4" "flask-appbuilder>=4.1.3" \
|
2022-10-04 23:53:33 +00:00
|
|
|
--replace "pathspec~=0.9.0" "pathspec"
|
2021-11-20 00:35:17 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
# Fix failing test on Hydra
|
|
|
|
substituteInPlace airflow/utils/db.py \
|
|
|
|
--replace "/tmp/sqlite_default.db" "$TMPDIR/sqlite_default.db"
|
2019-07-18 13:18:26 +00:00
|
|
|
'';
|
|
|
|
|
2022-01-12 14:43:09 +00:00
|
|
|
# allow for gunicorn processes to have access to Python packages
|
|
|
|
makeWrapperArgs = [
|
|
|
|
"--prefix PYTHONPATH : $PYTHONPATH"
|
|
|
|
];
|
2020-05-11 20:15:27 +00:00
|
|
|
|
2022-10-22 10:10:50 +00:00
|
|
|
postInstall = ''
|
|
|
|
cp -rv ${airflow-frontend}/static/dist $out/lib/${python.libPrefix}/site-packages/airflow/www/static
|
|
|
|
# Needed for pythonImportsCheck below
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
'';
|
|
|
|
|
2022-08-25 16:57:50 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"airflow"
|
2022-09-09 13:21:29 +00:00
|
|
|
] ++ providerImports;
|
2022-08-25 16:57:50 +00:00
|
|
|
|
2022-10-22 10:10:50 +00:00
|
|
|
preCheck = ''
|
2022-01-12 14:43:09 +00:00
|
|
|
export AIRFLOW_HOME=$HOME
|
|
|
|
export AIRFLOW__CORE__UNIT_TEST_MODE=True
|
|
|
|
export AIRFLOW_DB="$HOME/airflow.db"
|
|
|
|
export PATH=$PATH:$out/bin
|
|
|
|
|
|
|
|
airflow version
|
|
|
|
airflow db init
|
|
|
|
airflow db reset -y
|
2021-07-09 08:20:32 +00:00
|
|
|
'';
|
|
|
|
|
2021-11-20 00:33:39 +00:00
|
|
|
pytestFlagsArray = [
|
|
|
|
"tests/core/test_core.py"
|
|
|
|
];
|
|
|
|
|
2021-11-20 00:35:17 +00:00
|
|
|
disabledTests = lib.optionals stdenv.isDarwin [
|
2022-01-12 14:43:09 +00:00
|
|
|
"bash_operator_kill" # psutil.AccessDenied
|
2021-11-20 00:35:17 +00:00
|
|
|
];
|
|
|
|
|
2022-09-09 13:46:05 +00:00
|
|
|
# Updates yarn.lock and package.json
|
|
|
|
passthru.updateScript = writeScript "update.sh" ''
|
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#!nix-shell -i bash -p common-updater-scripts curl pcre "python3.withPackages (ps: with ps; [ pyyaml ])" yarn2nix
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
# Get new version
|
|
|
|
new_version="$(curl -s https://airflow.apache.org/docs/apache-airflow/stable/release_notes.html |
|
|
|
|
pcregrep -o1 'Airflow ([0-9.]+).' | head -1)"
|
|
|
|
update-source-version ${pname} "$new_version"
|
|
|
|
|
|
|
|
# Update frontend
|
|
|
|
cd ./pkgs/development/python-modules/apache-airflow
|
|
|
|
curl -O https://raw.githubusercontent.com/apache/airflow/$new_version/airflow/www/yarn.lock
|
|
|
|
curl -O https://raw.githubusercontent.com/apache/airflow/$new_version/airflow/www/package.json
|
2022-11-21 16:10:13 +00:00
|
|
|
# Revert this commit which seems to break with our version of yarn
|
|
|
|
# https://github.com/apache/airflow/commit/b9e133e40c2848b0d555051a99bf8d2816fd28a7
|
|
|
|
patch -p3 < 0001-Revert-fix-yarn-warning-from-d3-color-27139.patch
|
2022-09-09 13:46:05 +00:00
|
|
|
yarn2nix > yarn.nix
|
|
|
|
|
|
|
|
# update provider dependencies
|
|
|
|
./update-providers.py
|
|
|
|
'';
|
|
|
|
|
2022-10-22 10:43:43 +00:00
|
|
|
# Note on testing the web UI:
|
|
|
|
# You can (manually) test the web UI as follows:
|
|
|
|
#
|
|
|
|
# nix shell .#python3Packages.apache-airflow
|
2022-11-21 16:10:13 +00:00
|
|
|
# airflow db reset # WARNING: this will wipe any existing db state you might have!
|
2022-10-22 10:43:43 +00:00
|
|
|
# airflow db init
|
|
|
|
# airflow standalone
|
|
|
|
#
|
|
|
|
# Then navigate to the localhost URL using the credentials printed, try
|
|
|
|
# triggering the 'example_bash_operator' and 'example_bash_operator' DAGs and
|
|
|
|
# see if they report success.
|
|
|
|
|
2019-07-18 13:18:26 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Programmatically author, schedule and monitor data pipelines";
|
2021-12-28 16:53:47 +00:00
|
|
|
homepage = "https://airflow.apache.org/";
|
2019-07-18 13:18:26 +00:00
|
|
|
license = licenses.asl20;
|
2022-09-12 08:21:01 +00:00
|
|
|
maintainers = with maintainers; [ bhipple gbpdt ingenieroariel ];
|
2019-07-18 13:18:26 +00:00
|
|
|
};
|
|
|
|
}
|