mirror of
https://github.com/logos-messaging/logos-messaging-go.git
synced 2026-01-02 14:03:06 +00:00
This way we can build node or the library locally using: ```sh nix build nix build .#node nix build .#library ``` Or just start a shell with Go `1.19.x` using: ``` nix develop ``` Which simply has the same environment as the build shell for the node. One known snag is that there is currently no simple way to keep `vendorSha256` updated to match the contents of `go.mod` and `go.sum`. For more details see: https://discourse.nixos.org/t/how-should-i-build-a-go-package-from-local-source/19490/8 One way around this would be to have our own `vendor` folder, but that's also a pretty ugly solution that requires manual updating. Resolves: https://github.com/waku-org/go-waku/issues/256 Signed-off-by: Jakub Sokołowski <jakub@status.im>
45 lines
1.4 KiB
Nix
45 lines
1.4 KiB
Nix
{
|
|
description = "Nix flake for Go implementaion of Waku v2 node.";
|
|
|
|
inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-22.11;
|
|
|
|
outputs = { self, nixpkgs }:
|
|
let
|
|
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
|
|
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.buildGo119Module {
|
|
name = "go-waku";
|
|
src = self;
|
|
inherit subPackages;
|
|
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-TvQfLQEYDujfXInQ+i/LoSGtedozZvX8WgzpqiryYHY=";
|
|
};
|
|
in rec {
|
|
packages = forAllSystems (system: {
|
|
node = buildPackage system ["cmd/waku"];
|
|
library = buildPackage system ["library"];
|
|
});
|
|
|
|
defaultPackage = forAllSystems (system:
|
|
buildPackage system ["cmd/waku"]
|
|
);
|
|
|
|
devShells.default = forAllSystems (system:
|
|
packages.${system}.node
|
|
);
|
|
};
|
|
}
|