forked from pgcentralfoundation/pgrx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
91 lines (84 loc) · 2.51 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
{
description = "Postgres extensions in Rust.";
inputs = {
naersk.url = "github:nix-community/naersk";
naersk.inputs.nixpkgs.follows = "nixpkgs";
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
};
outputs = { self, nixpkgs, naersk }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
in
{
defaultPackage = forAllSystems (system: (import nixpkgs {
inherit system;
overlays = [ self.overlay ];
}).cargo-pgx);
packages = forAllSystems (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlay ];
};
in
{
inherit (pkgs) cargo-pgx;
});
overlay = final: prev: {
cargo-pgx = final.callPackage ./cargo-pgx { inherit naersk; };
};
devShell = forAllSystems (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlay ];
};
in
pkgs.mkShell {
inputsFrom = with pkgs; [
postgresql_10
postgresql_11
postgresql_12
postgresql_13
];
buildInputs = with pkgs; [
rustfmt
nixpkgs-fmt
cargo-pgx
postgresql
];
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
PGX_PG_SYS_SKIP_BINDING_REWRITE = "1";
BINDGEN_EXTRA_CLANG_ARGS = [
''-I"${pkgs.llvmPackages.libclang.lib}/lib/clang/${pkgs.llvmPackages.libclang.version}/include"''
"-I ${pkgs.glibc.dev}/include"
];
});
checks = forAllSystems (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlay ];
};
in
{
format = pkgs.runCommand "check-format"
{
buildInputs = with pkgs; [ rustfmt cargo ];
} ''
${pkgs.rustfmt}/bin/cargo-fmt fmt --manifest-path ${./.}/Cargo.toml -- --check
${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt --check ${./.}
touch $out # it worked!
'';
pkgs-cargo-pgx = pkgs.cargo-pgx.out;
});
defaultTemplate = self.templates.default;
templates = {
default = {
path = ./nix/templates/default;
description = "A basic PGX extension";
};
};
};
}