|
1 | 1 | {
|
2 |
| - description = "PostgreSQL data connector"; |
| 2 | + description = "BiiQuery data connector"; |
3 | 3 |
|
4 | 4 | inputs = {
|
5 |
| - nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable; |
6 |
| - flake-utils.url = github:numtide/flake-utils; |
| 5 | + nixpkgs.url = "github:NixOS/nixpkgs?branch=nixos-unstable"; |
| 6 | + flake-utils.url = "github:numtide/flake-utils"; |
7 | 7 |
|
8 | 8 | crane = {
|
9 | 9 | url = "github:ipetkov/crane";
|
10 | 10 | inputs.nixpkgs.follows = "nixpkgs";
|
11 |
| - inputs.rust-overlay.follows = "rust-overlay"; |
12 |
| - inputs.flake-utils.follows = "flake-utils"; |
13 | 11 | };
|
14 | 12 |
|
15 | 13 | rust-overlay = {
|
16 | 14 | url = "github:oxalica/rust-overlay";
|
17 | 15 | inputs = {
|
18 | 16 | nixpkgs.follows = "nixpkgs";
|
19 |
| - flake-utils.follows = "flake-utils"; |
20 | 17 | };
|
21 | 18 | };
|
22 | 19 | };
|
|
29 | 26 | overlays = [ rust-overlay.overlays.default ];
|
30 | 27 | };
|
31 | 28 |
|
32 |
| - # Edit ./nix/ndc-agent.nix to adjust library and buildtime |
33 |
| - # dependencies or other build configuration for postgres-agent |
34 |
| - crateExpression = import ./nix/ndc-agent.nix; |
35 |
| - |
36 |
| - # cockroachExpression = import ./nix/cockroach-agent.nix; |
37 |
| - cargoBuild = import ./nix/cargo-build.nix; |
38 |
| - |
39 |
| - # create binaries for a given NDC |
40 |
| - make-binaries = (binary-name: { |
41 |
| - inherit binary-name; |
| 29 | + rust = import ./nix/rust.nix { |
| 30 | + inherit nixpkgs rust-overlay crane localSystem; |
| 31 | + }; |
| 32 | + in |
| 33 | + { |
| 34 | + packages = { |
42 | 35 | # a binary for whichever is the local computer
|
43 |
| - local-system = cargoBuild { |
44 |
| - inherit binary-name crateExpression nixpkgs crane rust-overlay localSystem; |
45 |
| - }; |
| 36 | + default = rust.callPackage ./nix/app.nix { }; |
| 37 | + |
46 | 38 | # cross compiler an x86_64 linux binary
|
47 |
| - x86_64-linux = cargoBuild { |
48 |
| - inherit binary-name crateExpression nixpkgs crane rust-overlay localSystem; |
| 39 | + x86_64-linux = (import ./nix/rust.nix { |
| 40 | + inherit nixpkgs rust-overlay crane localSystem; |
49 | 41 | crossSystem = "x86_64-linux";
|
50 |
| - }; |
| 42 | + }).callPackage ./nix/app.nix |
| 43 | + { }; |
51 | 44 | # cross compile a aarch64 linux binary
|
52 |
| - aarch64-linux = cargoBuild { |
53 |
| - inherit binary-name crateExpression nixpkgs crane rust-overlay localSystem; |
| 45 | + aarch64-linux = (import ./nix/rust.nix { |
| 46 | + inherit nixpkgs rust-overlay crane localSystem; |
54 | 47 | crossSystem = "aarch64-linux";
|
| 48 | + }).callPackage ./nix/app.nix |
| 49 | + { }; |
| 50 | + |
| 51 | + # docker for local system |
| 52 | + docker = pkgs.callPackage ./nix/docker.nix { |
| 53 | + package = self.packages.${localSystem}.default; |
| 54 | + image-name = "ghcr.io/hasura/ndc-bigquery"; |
| 55 | + tag = "dev"; |
| 56 | + }; |
| 57 | + # docker for x86_64-linux |
| 58 | + docker-x86_64-linux = pkgs.callPackage ./nix/docker.nix { |
| 59 | + package = self.packages.${localSystem}.x86_64-linux; |
| 60 | + architecture = "amd64"; |
| 61 | + image-name = "ghcr.io/hasura/ndc-bigquery-x86_64"; |
| 62 | + }; |
| 63 | + # docker for aarch64-linux |
| 64 | + docker-aarch64-linux = pkgs.callPackage ./nix/docker.nix { |
| 65 | + package = self.packages.${localSystem}.aarch64-linux; |
| 66 | + architecture = "arm64"; |
| 67 | + image-name = "ghcr.io/hasura/ndc-bigquery-aarch64"; |
55 | 68 | };
|
56 |
| - }); |
57 |
| - |
58 |
| - # given the binaries, return the flake targets that build Docker etc |
59 |
| - make-packages = |
60 |
| - (ndc-binaries: |
61 |
| - let name = ndc-binaries.binary-name; in { |
62 |
| - # binary compiled on local system |
63 |
| - "${name}" = ndc-binaries.local-system; |
64 |
| - # binary compiled for x86_64-linux |
65 |
| - "${name}-x86_64-linux" = ndc-binaries.x86_64-linux; |
66 |
| - # binary compiled for aarch64-linux |
67 |
| - "${name}-aarch64-linux" = ndc-binaries.aarch64-linux; |
68 |
| - # docker for local system |
69 |
| - "${name}-docker" = pkgs.callPackage ./nix/docker.nix { |
70 |
| - ndc-agent = ndc-binaries.local-system; |
71 |
| - binary-name = name; |
72 |
| - image-name = "ghcr.io/hasura/${name}"; |
73 |
| - tag = "dev"; |
74 |
| - }; |
75 |
| - # docker for x86_64-linux |
76 |
| - "${name}-docker-x86_64-linux" = pkgs.callPackage ./nix/docker.nix { |
77 |
| - ndc-agent = ndc-binaries.x86_64-linux; |
78 |
| - architecture = "amd64"; |
79 |
| - binary-name = name; |
80 |
| - image-name = "ghcr.io/hasura/${name}-x86_64"; |
81 |
| - }; |
82 |
| - # docker for aarch64-linux |
83 |
| - "${name}-docker-aarch64-linux" = pkgs.callPackage ./nix/docker.nix { |
84 |
| - ndc-agent = ndc-binaries.aarch64-linux; |
85 |
| - architecture = "arm64"; |
86 |
| - binary-name = name; |
87 |
| - image-name = "ghcr.io/hasura/${name}-aarch64"; |
88 |
| - }; |
89 |
| - }); |
90 |
| - |
91 |
| - postgres-binaries = make-binaries "ndc-postgres"; |
92 |
| - cockroach-binaries = make-binaries "ndc-cockroach"; |
93 |
| - citus-binaries = make-binaries "ndc-citus"; |
94 |
| - |
95 |
| - inherit (postgres-binaries.local-system) cargoArtifacts rustToolchain craneLib buildArgs; |
96 |
| - |
97 |
| - in |
98 |
| - { |
99 |
| - packages = builtins.foldl' (x: y: x // y) { } [ |
100 |
| - (make-packages postgres-binaries) |
101 |
| - (make-packages cockroach-binaries) |
102 |
| - (make-packages citus-binaries) |
103 |
| - ] // { |
104 |
| - default = postgres-binaries.local-system; |
105 | 69 |
|
106 | 70 | publish-docker-image = pkgs.writeShellApplication {
|
107 | 71 | name = "publish-docker-image";
|
|
110 | 74 | };
|
111 | 75 | };
|
112 | 76 |
|
| 77 | + apps = { |
| 78 | + default = self.apps.${localSystem}.connector; |
| 79 | + |
| 80 | + connector = { |
| 81 | + type = "app"; |
| 82 | + program = "${self.packages.${localSystem}.default}/bin/ndc-bigquery"; |
| 83 | + }; |
| 84 | + |
| 85 | + cli = { |
| 86 | + type = "app"; |
| 87 | + program = "${self.packages.${localSystem}.default}/bin/ndc-bigquery-cli"; |
| 88 | + }; |
| 89 | + }; |
| 90 | + |
113 | 91 | checks = {
|
114 | 92 | # Build the crate as part of `nix flake check`
|
115 |
| - ndc-postgres = postgres-binaries.local-system; |
| 93 | + ndc-bigquery = self.packages.${localSystem}.default; |
116 | 94 | };
|
117 | 95 |
|
118 | 96 | formatter = pkgs.nixpkgs-fmt;
|
119 | 97 |
|
120 |
| - devShells.default = pkgs.mkShell { |
121 |
| - inputsFrom = builtins.attrValues self.checks.${localSystem}; |
122 |
| - nativeBuildInputs = [ |
123 |
| - # runtime |
124 |
| - pkgs.protobuf |
125 |
| - |
126 |
| - # development |
127 |
| - pkgs.cargo-edit |
128 |
| - pkgs.cargo-flamegraph |
129 |
| - pkgs.cargo-insta |
130 |
| - pkgs.cargo-machete |
131 |
| - pkgs.cargo-watch |
132 |
| - pkgs.just |
133 |
| - pkgs.k6 |
134 |
| - pkgs.nixpkgs-fmt |
135 |
| - pkgs.nodePackages.prettier |
136 |
| - pkgs.pkg-config |
137 |
| - pkgs.rnix-lsp |
138 |
| - pkgs.skopeo |
139 |
| - pkgs.nodePackages.prettier |
140 |
| - rustToolchain |
141 |
| - ]; |
| 98 | + devShells = { |
| 99 | + default = pkgs.mkShell { |
| 100 | + # include dependencies of the default package |
| 101 | + inputsFrom = [ self.packages.${localSystem}.default ]; |
| 102 | + |
| 103 | + # build-time inputs |
| 104 | + nativeBuildInputs = [ |
| 105 | + # Development |
| 106 | + pkgs.just |
| 107 | + pkgs.nixpkgs-fmt |
| 108 | + pkgs.nodePackages.prettier |
| 109 | + pkgs.moreutils |
| 110 | + |
| 111 | + # Rust |
| 112 | + pkgs.bacon |
| 113 | + pkgs.cargo-audit |
| 114 | + pkgs.cargo-edit |
| 115 | + pkgs.cargo-expand |
| 116 | + pkgs.cargo-flamegraph |
| 117 | + pkgs.cargo-insta |
| 118 | + pkgs.cargo-machete |
| 119 | + pkgs.cargo-nextest |
| 120 | + pkgs.cargo-watch |
| 121 | + rust.rustToolchain |
| 122 | + |
| 123 | + # Benchmarks |
| 124 | + pkgs.k6 |
| 125 | + |
| 126 | + # Deployment |
| 127 | + pkgs.skopeo |
| 128 | + ]; |
| 129 | + }; |
| 130 | + } // pkgs.lib.attrsets.optionalAttrs pkgs.hostPlatform.isLinux { |
| 131 | + # This performance-testing shell will only work on Linux. |
| 132 | + perf = pkgs.mkShell { |
| 133 | + inputsFrom = [ |
| 134 | + self.devShells.${localSystem}.default |
| 135 | + ]; |
| 136 | + |
| 137 | + # build-time inputs |
| 138 | + nativeBuildInputs = [ |
| 139 | + pkgs.heaptrack |
| 140 | + pkgs.linuxPackages_latest.perf |
| 141 | + pkgs.mold-wrapped |
| 142 | + pkgs.valgrind |
| 143 | + ]; |
| 144 | + }; |
142 | 145 | };
|
143 |
| - }); |
| 146 | + } |
| 147 | + ); |
144 | 148 | }
|
0 commit comments