45 , marshmallow-oneofschema
48 , openapi-spec-validator
50 , opentelemetry-exporter-otlp
69 , sqlalchemy-jsonfield
85 # Extra airflow providers to enable
86 , enabledProviders ? []
91 airflow-src = fetchFromGitHub rec {
94 rev = "refs/tags/${version}";
95 # Download using the git protocol rather than using tarballs, because the
96 # GitHub archive tarballs don't appear to include tests
98 hash = "sha256-+YbiKFZLigSDbHPaUKIl97kpezW1rIt/j09MMa6lwhQ=";
101 # airflow bundles a web interface, which is built using webpack by an undocumented shell script in airflow's source tree.
102 # This replicates this shell script, fixing bugs in yarn.lock and package.json
104 airflow-frontend = mkYarnPackage rec {
105 name = "airflow-frontend";
107 src = "${airflow-src}/airflow/www";
108 packageJSON = ./package.json;
110 offlineCache = fetchYarnDeps {
111 yarnLock = "${src}/yarn.lock";
112 hash = "sha256-WQKuQgNp35fU6z7owequXOSwoUGJDJYcUgkjPDMOops=";
117 # The webpack license plugin tries to create /licenses when given the
118 # original relative path
120 sed -i 's!../../../../licenses/LICENSES-ui.txt!licenses/LICENSES-ui.txt!' webpack.config.js
124 cp -r $node_modules node_modules
129 find package.json yarn.lock static/css static/js -type f | sort | xargs md5sum > static/dist/sum.md5
133 mkdir -p $out/static/
134 cp -r static/dist $out/static
138 # Import generated file with metadata for provider dependencies and imports.
139 # Enable additional providers using enabledProviders above.
140 providers = import ./providers.nix;
141 getProviderDeps = provider: map (dep: python.pkgs.${dep}) providers.${provider}.deps;
142 getProviderImports = provider: providers.${provider}.imports;
143 providerDependencies = lib.concatMap getProviderDeps enabledProviders;
144 providerImports = lib.concatMap getProviderImports enabledProviders;
146 buildPythonPackage rec {
147 pname = "apache-airflow";
151 disabled = pythonOlder "3.7";
153 propagatedBuildInputs = [
192 marshmallow-oneofschema
195 openapi-spec-validator
197 opentelemetry-exporter-otlp
223 ] ++ lib.optionals (pythonOlder "3.9") [
225 ] ++ providerDependencies;
231 nativeCheckInputs = [
238 # By default, source code of providers is included but unusable due to missing
239 # transitive dependencies. To enable a provider, add it to extraProviders
241 INSTALL_PROVIDERS_FROM_SOURCES = "true";
244 # https://github.com/apache/airflow/issues/33854
245 substituteInPlace pyproject.toml \
246 --replace '[project]' $'[project]\nname = "apache-airflow"\nversion = "${version}"'
247 '' + lib.optionalString stdenv.isDarwin ''
248 # Fix failing test on Hydra
249 substituteInPlace airflow/utils/db.py \
250 --replace "/tmp/sqlite_default.db" "$TMPDIR/sqlite_default.db"
260 # allow for gunicorn processes to have access to Python packages
262 "--prefix PYTHONPATH : $PYTHONPATH"
266 cp -rv ${airflow-frontend}/static/dist $out/${python.sitePackages}/airflow/www/static
267 # Needed for pythonImportsCheck below
268 export HOME=$(mktemp -d)
271 pythonImportsCheck = [
273 ] ++ providerImports;
276 export AIRFLOW_HOME=$HOME
277 export AIRFLOW__CORE__UNIT_TEST_MODE=True
278 export AIRFLOW_DB="$HOME/airflow.db"
279 export PATH=$PATH:$out/bin
287 "tests/core/test_core.py"
290 disabledTests = lib.optionals stdenv.isDarwin [
291 "bash_operator_kill" # psutil.AccessDenied
294 # Updates yarn.lock and package.json
295 passthru.updateScript = writeScript "update.sh" ''
296 #!/usr/bin/env nix-shell
297 #!nix-shell -i bash -p common-updater-scripts curl pcre "python3.withPackages (ps: with ps; [ pyyaml ])" yarn2nix
302 new_version="$(curl -s https://airflow.apache.org/docs/apache-airflow/stable/release_notes.html |
303 pcregrep -o1 'Airflow ([0-9.]+).' | head -1)"
304 update-source-version ${pname} "$new_version"
307 cd ./pkgs/servers/apache-airflow
308 curl -O https://raw.githubusercontent.com/apache/airflow/$new_version/airflow/www/yarn.lock
309 curl -O https://raw.githubusercontent.com/apache/airflow/$new_version/airflow/www/package.json
312 # update provider dependencies
313 ./update-providers.py
316 # Note on testing the web UI:
317 # You can (manually) test the web UI as follows:
319 # nix shell .#apache-airflow
320 # airflow db reset # WARNING: this will wipe any existing db state you might have!
324 # Then navigate to the localhost URL using the credentials printed, try
325 # triggering the 'example_bash_operator' and 'example_bash_operator' DAGs and
326 # see if they report success.
329 description = "Programmatically author, schedule and monitor data pipelines";
330 homepage = "https://airflow.apache.org/";
331 license = licenses.asl20;
332 maintainers = with maintainers; [ bhipple gbpdt ingenieroariel ];
333 knownVulnerabilities = [