-
Notifications
You must be signed in to change notification settings - Fork 17
/
flake.nix
94 lines (77 loc) · 2.37 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = { nixpkgs, ... }:
let
inherit (nixpkgs) lib;
package =
{ lib
, stdenv
, rustPlatform
, cmake
, makeWrapper
, Security
, SystemConfiguration
, buildType ? "release"
}:
rustPlatform.buildRustPackage {
name = "portier-broker";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = [ cmake makeWrapper ];
buildInputs = lib.optionals stdenv.isDarwin [ Security SystemConfiguration ];
doCheck = true;
inherit buildType;
# On Linux, release builds fail without this on a memcpy.
hardeningDisable = [ "strictoverflow" ];
postInstall = ''
mkdir $out/data
cp -r ./res ./tmpl ./lang $out/data/
rm $out/data/lang/*.po
wrapProgram $out/bin/portier-broker \
--set-default BROKER_DATA_DIR $out/data
'';
};
overlay = final: prev: {
portier-broker =
# TODO: aws-lc-rs still seems to build with the wrong SDK.
let appleSdk = final.darwin.apple_sdk_11_0;
in appleSdk.callPackage package {
inherit (appleSdk.frameworks) Security SystemConfiguration;
};
};
pkgs = lib.listToAttrs (map
(system: {
name = system;
value = import nixpkgs {
inherit system;
overlays = [ overlay ];
};
})
[
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
]);
forEachSystem = f: lib.mapAttrs (system: f) pkgs;
in
{
overlays.default = overlay;
packages = forEachSystem (pkgs: {
default = pkgs.portier-broker;
debug = pkgs.portier-broker.override { buildType = "debug"; };
});
devShells = forEachSystem (pkgs: {
default = pkgs.mkShell.override
{ inherit (pkgs.portier-broker) stdenv; }
{
nativeBuildInputs = pkgs.portier-broker.nativeBuildInputs
++ (with pkgs; [ git cargo-audit cargo-outdated ])
++ (with pkgs.rustPackages; [ rustfmt clippy ]);
buildInputs = pkgs.portier-broker.buildInputs;
};
});
};
}