Open blackgnezdo opened 2 years ago
I was looking for a solution myself, the folks on the forum assisted, and I now have a working shell.nix
that can use GCP (at least for accessing cloud storage, which is what I tested):
https://discourse.nixos.org/t/equivalent-of-pip-install-apache-beam-gcp/25377/5
Not exactly straightforward, and I couldn't work it out on my own without help, but it does work.
Just to add complexity, it doesn't work on HEAD at the moment, see https://github.com/NixOS/nixpkgs/issues/212691
Fortunately with a Nix Flake you can set the nixpkgs to a version that does work.
{
description = "GCP Dataflow setup";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/35f1f865c03671a4f75a6996000f03ac3dc3e472";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
beam = import ./beam.nix { inherit pkgs; };
shell = pkgs.mkShell {
packages = [
pkgs.gcc-unwrapped.lib
pkgs.poetry
beam.beam
];
};
in
{
beam = beam.beam;
# nix shell
defaultPackage = beam.beam;
# nix develop
devShells.default = shell;
});
}
{ pkgs ? import <nixpkgs> {} }:
{
beam = pkgs.python39.withPackages(ps: with ps; [
# [gcp] optionals.
cachetools
google-apitools
google-auth
google-auth-httplib2
google-cloud-datastore
google-cloud-pubsub
# google-cloud-pubsublite - Not found
google-cloud-bigquery
google-cloud-bigquery-storage
google-cloud-core
google-cloud-bigtable
google-cloud-spanner
google-cloud-dlp
google-cloud-language
google-cloud-videointelligence
google-cloud-vision
# google-cloud-recommendations-ai - Not found
# End of [gcp] section.
google-cloud-storage
apache-beam
grpcio
]);
}
Then you can do nix shell
to add the package to your shell, or nix develop
to start a new shell with the right packages in it.
Project description
I was happy to find that apache beam is already packaged. Sadly, trying to run an example quickly resulted in a missing runtime dependency:
Some place else
pip install apache-beam[gcp]
would suffice, but this is clearly not a Nix way.Metadata