-
-
Notifications
You must be signed in to change notification settings - Fork 163
/
flake.nix
159 lines (138 loc) · 4.53 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
149
150
151
152
153
154
155
156
157
158
159
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";
nixpkgs-for-php.url = "github:nixos/nixpkgs/nixos-22.05";
};
outputs =
{ self
, nixpkgs
, nixpkgs-for-php
, ...
}@inputs:
let
supportedSystems = [ "aarch64-darwin" "x86_64-darwin" "x86_64-linux" "aarch64-linux" ];
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
in
{
devShell = forAllSystems (system: inputs.self.devShells.${system}.default);
devShells = forAllSystems
(system:
let
pkgs = import nixpkgs {
inherit system;
};
phpPkgs = import nixpkgs-for-php {
inherit system;
};
phpEnv = pkgs.mkShell {
name = "gh-event-forwarder";
buildInputs = with pkgs; [
nix-prefetch-git
phpPkgs.php
phpPkgs.phpPackages.composer
git
curl
bash
];
};
in
{
default = pkgs.mkShell {
name = "gh-event-forwarder";
nativeBuildInputs = with pkgs; [
nix # so in --pure mode we actually find the "correct" nix
bash
nix-prefetch-git
rustc
cargo
clippy
rustfmt
pkg-config
git
];
buildInputs = with pkgs; [
] ++ lib.optionals stdenv.isDarwin [ darwin.Security libiconv ];
postHook = ''
checkPhase() (
cd "${builtins.toString ./.}/ofborg"
set -x
cargo fmt
git diff --exit-code
cargofmtexit=$?
cargo clippy
cargoclippyexit=$?
cargo build && cargo test
cargotestexit=$?
sum=$((cargofmtexit + cargoclippyexit + cargotestexit))
exit $sum
)
'';
RUSTFLAGS = "-D warnings";
RUST_BACKTRACE = "1";
RUST_LOG = "ofborg=debug";
NIX_PATH = "nixpkgs=${pkgs.path}";
passthru.phpEnv = phpEnv;
};
});
packages = forAllSystems (system:
let
pkgs = import nixpkgs {
inherit system;
};
phpPkgs = import nixpkgs-for-php {
inherit system;
};
pkg = pkgs.rustPlatform.buildRustPackage {
name = "ofborg";
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
nativeBuildInputs = with pkgs; [
pkgconfig
pkgs.rustPackages.clippy
];
buildInputs = with pkgs; [
] ++ lib.optionals pkgs.stdenv.isDarwin (with pkgs; [
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.CoreFoundation
]);
preBuild = ''
cargo clippy
'';
doCheck = false; # Tests require access to a /nix/ and a nix daemon
checkInputs = with pkgs; [
nix
];
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"hubcaps-0.6.2" = "sha256-yyHOCxUsehvtYfttRY4T9TDrJhSKGpJRa/SX3Sd1TNc=";
};
};
};
in
{
inherit pkg;
ofborg.rs = pkgs.runCommand "ofborg-rs-symlink-compat" { src = pkg; } ''
mkdir -p $out/bin
for f in $(find $src -type f); do
bn=$(basename "$f")
ln -s "$f" "$out/bin/$bn"
# Rust 1.n? or Cargo starting outputting bins with dashes
# instead of underscores ... breaking all the callers.
if echo "$bn" | grep -q "-"; then
ln -s "$f" "$out/bin/$(echo "$bn" | tr '-' '_')"
fi
done
test -e $out/bin/builder
test -e $out/bin/github_comment_filter
test -e $out/bin/github_comment_poster
test -e $out/bin/log_message_collector
test -e $out/bin/evaluation_filter
'';
ofborg.php = import ./php { pkgs = phpPkgs; };
});
hydraJobs = {
buildRs = forAllSystems (system: self.packages.${system}.ofborg.rs);
buildPhp = self.packages.x86_64-linux.ofborg.php;
};
};
}