forked from waku-org/go-waku
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
64 lines (57 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
63
64
{
description = "Nix flake for Go implementaion of Waku v2 node.";
inputs.nixpkgs.url = github:NixOS/nixpkgs/master;
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);
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
buildPackage = system: subPackages:
let
pkgs = nixpkgsFor.${system};
commit = builtins.substring 0 7 (self.rev or "dirty");
version = builtins.readFile ./VERSION;
in pkgs.buildGo120Module {
name = "go-waku";
src = self;
inherit subPackages;
tags = [ ];
ldflags = [
"-X github.com/waku-org/go-waku/waku/v2/node.GitCommit=${commit}"
"-X github.com/waku-org/go-waku/waku/v2/node.Version=${version}"
];
doCheck = false;
# FIXME: This needs to be manually changed when updating modules.
vendorSha256 = "sha256-1m5byn1CVD8Awzbo9XY94FgitC+uetTfon/8bBh5DiE=";
# Fix for 'nix run' trying to execute 'go-waku'.
meta = { mainProgram = "waku"; };
};
in rec {
packages = forAllSystems (system: {
node = buildPackage system ["cmd/waku"];
library = buildPackage system ["library/c"];
});
defaultPackage = forAllSystems (system:
buildPackage system ["cmd/waku"]
);
devShells = forAllSystems (system: let
pkgs = nixpkgsFor.${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 ];
};
});
};
}