-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
148 lines (129 loc) · 4.36 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
{
description = "BigQuery data connector";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs?branch=nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
};
outputs = { self, nixpkgs, flake-utils, crane, rust-overlay }:
flake-utils.lib.eachDefaultSystem (localSystem:
let
pkgs = import nixpkgs {
system = localSystem;
overlays = [ rust-overlay.overlays.default ];
};
rust = import ./nix/rust.nix {
inherit nixpkgs rust-overlay crane localSystem;
};
in
{
packages = {
# a binary for whichever is the local computer
default = rust.callPackage ./nix/app.nix { };
# cross compiler an x86_64 linux binary
x86_64-linux = (import ./nix/rust.nix {
inherit nixpkgs rust-overlay crane localSystem;
crossSystem = "x86_64-linux";
}).callPackage ./nix/app.nix
{ };
# cross compile a aarch64 linux binary
aarch64-linux = (import ./nix/rust.nix {
inherit nixpkgs rust-overlay crane localSystem;
crossSystem = "aarch64-linux";
}).callPackage ./nix/app.nix
{ };
# docker for local system
docker = pkgs.callPackage ./nix/docker.nix {
package = self.packages.${localSystem}.default;
image-name = "ghcr.io/hasura/ndc-bigquery";
tag = "dev";
};
# docker for x86_64-linux
docker-x86_64-linux = pkgs.callPackage ./nix/docker.nix {
package = self.packages.${localSystem}.x86_64-linux;
architecture = "amd64";
image-name = "ghcr.io/hasura/ndc-bigquery-x86_64";
};
# docker for aarch64-linux
docker-aarch64-linux = pkgs.callPackage ./nix/docker.nix {
package = self.packages.${localSystem}.aarch64-linux;
architecture = "arm64";
image-name = "ghcr.io/hasura/ndc-bigquery-aarch64";
};
publish-docker-image = pkgs.writeShellApplication {
name = "publish-docker-image";
runtimeInputs = with pkgs; [ coreutils skopeo ];
text = builtins.readFile ./ci/deploy.sh;
};
};
apps = {
default = self.apps.${localSystem}.connector;
connector = {
type = "app";
program = "${self.packages.${localSystem}.default}/bin/ndc-bigquery";
};
cli = {
type = "app";
program = "${self.packages.${localSystem}.default}/bin/ndc-bigquery-cli";
};
};
checks = {
# Build the crate as part of `nix flake check`
ndc-bigquery = self.packages.${localSystem}.default;
};
formatter = pkgs.nixpkgs-fmt;
devShells = {
default = pkgs.mkShell {
# include dependencies of the default package
inputsFrom = [ self.packages.${localSystem}.default ];
# build-time inputs
nativeBuildInputs = [
# Development
pkgs.just
pkgs.nixpkgs-fmt
pkgs.nodePackages.prettier
pkgs.moreutils
# Rust
pkgs.bacon
pkgs.cargo-audit
pkgs.cargo-edit
pkgs.cargo-expand
pkgs.cargo-flamegraph
pkgs.cargo-insta
pkgs.cargo-machete
pkgs.cargo-nextest
pkgs.cargo-watch
rust.rustToolchain
# Benchmarks
pkgs.k6
# Deployment
pkgs.skopeo
];
};
} // pkgs.lib.attrsets.optionalAttrs pkgs.hostPlatform.isLinux {
# This performance-testing shell will only work on Linux.
perf = pkgs.mkShell {
inputsFrom = [
self.devShells.${localSystem}.default
];
# build-time inputs
nativeBuildInputs = [
pkgs.heaptrack
pkgs.linuxPackages_latest.perf
pkgs.mold-wrapped
pkgs.valgrind
];
};
};
}
);
}