-
Notifications
You must be signed in to change notification settings - Fork 43
/
flake.nix
62 lines (58 loc) · 2.1 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
{
description = "Nix flake for Go implementaion of Waku v2 node.";
inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-23.11;
outputs = { self, nixpkgs }:
let
supportedSystems = [
"x86_64-linux" "i686-linux" "aarch64-linux"
"x86_64-darwin" "aarch64-darwin"
];
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
pkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
in rec {
packages = forAllSystems (system: let
pkgs = pkgsFor.${system};
os = pkgs.stdenv.hostPlatform.uname.system;
sttLibExtMap = { Windows = "lib"; Darwin = "a"; Linux = "a"; };
dynLibExtMap = { Windows = "dll"; Darwin = "dylib"; Linux = "so"; };
buildPackage = pkgs.callPackage ./default.nix;
in rec {
default = node;
node = buildPackage {
inherit self;
subPkgs = ["cmd/waku"];
};
static-library = buildPackage {
inherit self;
subPkgs = ["library/c"];
ldflags = ["-buildmode=c-archive"];
output = "libgowaku.${sttLibExtMap.${os}}";
};
# FIXME: Compilation fails with:
# relocation R_X86_64_TPOFF32 against runtime.tlsg can not be
# used when making a shared object; recompile with -fPIC
dynamic-library = buildPackage {
inherit self;
subPkgs = ["library/c"];
ldflags = ["-buildmode=c-shared"];
output = "libgowaku.${dynLibExtMap.${os}}";
};
});
devShells = forAllSystems (system: let
pkgs = pkgsFor.${system};
inherit (pkgs) lib stdenv mkShell;
in {
default = mkShell {
GOFLAGS = "-trimpath"; # Drop -mod=vendor
inputsFrom = [ packages.${system}.node ];
buildInputs = with pkgs; [ golangci-lint ];
nativeBuildInputs = lib.optional stdenv.isDarwin [
(pkgs.xcodeenv.composeXcodeWrapper { version = "14.2"; allowHigher = true; })
];
};
fpm = mkShell {
buildInputs = with pkgs; [ fpm ];
};
});
};
}