-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
117 lines (105 loc) · 3.55 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
{
description = "SQL Server 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";
flake-utils.follows = "flake-utils";
};
};
};
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-sqlserver";
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-sqlserver-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-sqlserver-aarch64";
};
publish-docker-image = pkgs.writeShellApplication {
name = "publish-docker-image";
runtimeInputs = with pkgs; [ coreutils skopeo ];
text = builtins.readFile ./ci/deploy.sh;
};
};
checks = {
# Build the crate as part of `nix flake check`
ndc-sqlserver = self.packages.${localSystem}.default;
};
formatter = pkgs.nixpkgs-fmt;
devShells.default = pkgs.mkShell {
inputsFrom = builtins.attrValues self.checks.${localSystem};
nativeBuildInputs = [
# runtime
pkgs.protobuf
# development
pkgs.cargo-edit
pkgs.cargo-flamegraph
pkgs.cargo-insta
pkgs.cargo-machete
pkgs.cargo-nextest
pkgs.cargo-watch
pkgs.just
pkgs.k6
pkgs.nixpkgs-fmt
pkgs.nodePackages.prettier
pkgs.pkg-config
pkgs.skopeo
rust.rustToolchain
] ++ (
pkgs.lib.optionals
pkgs.stdenv.isLinux
[
pkgs.heaptrack
pkgs.linuxPackages_latest.perf
pkgs.mold-wrapped
pkgs.valgrind
]
);
};
});
}