-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathflake.nix
136 lines (129 loc) · 5.15 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
{
description = "zig-libp2p";
inputs.nixpkgs.url = "github:nixos/nixpkgs/release-22.05";
inputs.nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.zig-overlay = {
url = "github:mitchellh/zig-overlay";
inputs = {
nixpkgs.follows = "nixpkgs-unstable";
flake-utils.follows = "flake-utils";
};
};
inputs.zls.url = "github:zigtools/zls";
outputs = { self, nixpkgs, nixpkgs-unstable, flake-utils, zig-overlay, zls }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { system = system; };
pkgs-unstable = import nixpkgs-unstable { system = system; };
zig = zig-overlay.packages.${system}."0.10.1";
# zig = zig-overlay.packages.${system}."master";
zig-deps = (import ./zig-deps.nix) { inherit pkgs; };
zig-msquic-flake = ((import ./zig-msquic/flake.nix).outputs inputs);
openssl = zig-msquic-flake.packages.${system}.openssl;
in
{
packages.libmsquic = zig-msquic-flake.packages.${system}.libmsquic;
packages.libmsquic-debug = zig-msquic-flake.packages.${system}.libmsquic-debug;
packages.zig = zig;
packages.zls = zls.packages.${system}.default;
# packages.zls = pkgs.stdenvNoCC.mkDerivation {
# name = "zls";
# version = "master";
# src = pkgs.fetchFromGitHub {
# owner = "zigtools";
# repo = "zls";
# rev = "0.9.0";
# fetchSubmodules = true;
# sha256 = "sha256-MVo21qNCZop/HXBqrPcosGbRY+W69KNCc1DfnH47GsI=";
# # sha256 = pkgs.lib.fakeSha256;
# };
# nativeBuildInputs = [
# deps.zig
# pkgs.autoPatchelfHook # Automatically setup the loader, and do the magic
# ];
# dontConfigure = true;
# dontInstall = true;
# buildPhase = ''
# mkdir -p $out
# zig build install -Drelease-safe=true -Ddata_version=master --prefix $out
# '';
# XDG_CACHE_HOME = ".cache";
# };
packages.interop = pkgs.stdenv.mkDerivation
{
name = "interop";
src = ./.;
nativeBuildInputs =
(if pkgs.stdenv.isDarwin
then
(with pkgs.darwin.apple_sdk.frameworks;
[ ])
else [
pkgs.autoPatchelfHook # Automatically setup the loader, and do the magic
]);
buildInputs = [
zig
openssl
]
++ (if pkgs.stdenv.isDarwin
then
(with pkgs.darwin.apple_sdk.frameworks;
[ Security Foundation ])
else [ ]);
LIBSYSTEM_INCLUDE = (if pkgs.stdenv.isDarwin then
"${pkgs.darwin.Libsystem.outPath}/include" else "");
LIB_MSQUIC = "${self.packages.${system}.libmsquic}";
LIB_OPENSSL = "${openssl.dev}";
ZIG_DEPS = "${zig-deps.depsJson}";
buildPhase = ''
# build_dir=$(mktemp -d)
# cp -r . $build_dir
# cd $build_dir
export HOME=$PWD
${zig}/bin/zig build ${(if (pkgs.stdenv.isLinux && pkgs.stdenv.isx86_64) then "-Dcpu=x86_64" else "")} interop
'';
installPhase = ''
cp -r zig-out $out
'';
};
packages.interopContainer = pkgs.dockerTools.buildImage {
name = "interop-runner";
config = {
Cmd = [ "${self.packages.${system}.interop}/bin/interop" ];
};
};
packages.zig-libp2p-fhs = (pkgs.buildFHSUserEnv {
name = "code-server-env";
targetPkgs = pkgs: (with pkgs;
[ glibc openssl ]);
runScript = "/usr/bin/bash";
});
devShells.nonNixLinux = self.devShell.${system} // self.packages.${system}.zig-libp2p-fhs.env;
devShell =
pkgs.mkShell
rec {
buildInputs = [
zig
self.packages.${system}.zls
openssl
# pkgs.pkg-config
]
++ (if pkgs.stdenv.isDarwin
then
(with pkgs.darwin.apple_sdk.frameworks;
[ Security Foundation ])
else [ pkgs.glibc ]);
# PKG_CONFIG_PATH = "${pkgs.openssl_3_0.dev}/lib/pkgconfig";
# FRAMEWORKS = "${pkgs.darwin.apple_sdk.frameworks.Security}/Library/Frameworks:${pkgs.darwin.apple_sdk.frameworks.Foundation}/Library/Frameworks";
LIBSYSTEM_INCLUDE = (if pkgs.stdenv.isDarwin then
"${pkgs.darwin.Libsystem.outPath}/include" else "");
PB_INCLUDE = "${pkgs.protobufc}/include";
LIB_MSQUIC = "${self.packages.${system}.libmsquic}";
LIB_MSQUIC_DEBUG = "${self.packages.${system}.libmsquic-debug}";
LIB_OPENSSL = "${openssl.dev}";
ZIG_DEPS = "${zig-deps.depsJson}";
ELF_INTERPRETER = (if pkgs.stdenv.isLinux then "${pkgs.glibc}/lib/ld-linux-x86-64.so.2" else "");
};
});
}