Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch all go packages to buildGoModule #64

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ jobs:
uses: actions/[email protected]

- name: Install Nix ❄️
uses: cachix/install-nix-action@v13
uses: cachix/install-nix-action@v15
with:
install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
extra_nix_config: |
experimental-features = nix-command flakes

Expand Down
15 changes: 1 addition & 14 deletions checks.nix
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
{ packages, inputs, pkgs, system }:
let
go-source-inputs = (import ./sync-go-modules/go-source-inputs.nix) { inherit inputs; };
go-modules-check = (import ./sync-go-modules) { inherit pkgs go-source-inputs; };
in
{ packages, inputs, system }:
{
pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
nix-linter.enable = true;
ormolu.enable = true;
sync-go-modules = {
enable = true;
name = "go-modules-check";
entry = "${go-modules-check} -l";
files = "(\\.(lock|narHash)|flake.nix)$";
language = "system";
pass_filenames = false;
};
};
};
} // packages # adding packages here ensures that every attr gets built on check
78 changes: 22 additions & 56 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 12 additions & 13 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
# Rust Inputs
naersk.url = github:nmattia/naersk;

# Go Inputs
gomod2nix.url = github:JonathanLorimer/gomod2nix/allow-custom-vendors;

# Freshautomations inputs
stoml-src.url = github:freshautomations/stoml;
stoml-src.flake = false;
Expand All @@ -31,8 +28,11 @@
relayer-src.flake = false;

# Chain Sources
gaia6-src.flake = false;
gaia6-src.url = github:cosmos/gaia/v6.0.1;
gaia6_0_2-src.flake = false;
gaia6_0_2-src.url = github:cosmos/gaia/v6.0.2;

gaia6_0_3-src.flake = false;
gaia6_0_3-src.url = github:cosmos/gaia/v6.0.3;

gaia5-src.flake = false;
gaia5-src.url = github:cosmos/gaia/v5.0.8;
Expand Down Expand Up @@ -69,10 +69,7 @@
with inputs.flake-utils.lib;
eachDefaultSystem (system:
let
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ inputs.gomod2nix.overlay ];
};
pkgs = import inputs.nixpkgs { inherit system; };
eval-pkgs = import inputs.nixpkgs { system = "x86_64-linux"; };
resources = (import ./resources.nix) { inherit inputs pkgs eval-pkgs system; };
in
Expand All @@ -83,7 +80,7 @@

# nix flake check
checks = (import ./checks.nix) {
inherit inputs pkgs system;
inherit inputs system;
packages = resources.packages;
};

Expand All @@ -93,12 +90,14 @@
# nix run .#<app>
apps = {
hermes = mkApp { name = "hermes"; drv = packages.hermes; };
gaia = mkApp { name = "gaia"; drv = packages.gaia5; exePath = "/bin/gaiad"; };
gaia = mkApp { name = "gaia"; drv = packages.gaia6_0_3; exePath = "/bin/gaiad"; };
gaia4 = mkApp { name = "gaia"; drv = packages.gaia4; exePath = "/bin/gaiad"; };
gaia5 = mkApp { name = "gaia"; drv = packages.gaia5; exePath = "/bin/gaiad"; };
gaia6 = mkApp { name = "gaia"; drv = packages.gaia6; exePath = "/bin/gaiad"; };
gaia6 = mkApp { name = "gaia"; drv = packages.gaia6_0_3; exePath = "/bin/gaiad"; };
gaia6_0_2 = mkApp { name = "gaia"; drv = packages.gaia6_0_2; exePath = "/bin/gaiad"; };
gaia6_0_3 = mkApp { name = "gaia"; drv = packages.gaia6_0_3; exePath = "/bin/gaiad"; };
cosmovisor = mkApp { name = "cosmovisor"; drv = packages.cosmovisor; };
simd = mkApp { name = "simd"; drv = packages.cosmos-sdk; };
simd = mkApp { name = "simd"; drv = packages.simd; };
stoml = mkApp { name = "stoml"; drv = packages.stoml; };
sconfig = mkApp { name = "sconfig"; drv = packages.sconfig; };
gm = mkApp { name = "gm"; drv = packages.gm; };
Expand Down
106 changes: 76 additions & 30 deletions resources.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,101 @@
# good idea to check the inputs attrset in flake.nix!
with inputs;
let
cleanSourceWithRegexes = src: regexes: with pkgs.lib; with builtins; cleanSourceWith {
filter = (path: _:
any (r: match r path == null) regexes
);
inherit src;
};

# Cosmos packages
packages = rec {
stoml = (import ./resources/stoml) { inherit pkgs stoml-src; };
sconfig = (import ./resources/sconfig) { inherit pkgs sconfig-src; };
gm = with pkgs; (import ./resources/gm) {
inherit ibc-rs-src shellcheck lib makeWrapper gnused;
stoml = packages.stoml;
sconfig = packages.sconfig;
mkDerivation = stdenv.mkDerivation;

# Go packages
stoml = pkgs.buildGoModule {
name = "stoml";
src = stoml-src;
vendorSha256 = "sha256-37PcS7qVQ+IVZddcm+KbUjRjql7KIzynVGKpIHAk5GY=";
};
sconfig = pkgs.buildGoModule {
name = "sconfig";
src = sconfig-src;
vendorSha256 = "sha256-ytpye6zEZC4oLrif8xe6Vr99lblule9HiAyZsSisIPg=";
};
cosmovisor = pkgs.buildGoModule {
name = "cosmovisor";
src = "${cosmos-sdk-src}/cosmovisor";
vendorSha256 = "sha256-OAXWrwpartjgSP7oeNvDJ7cTR9lyYVNhEM8HUnv3acE=";
doCheck = false;
};
simd = pkgs.buildGoModule {
name = "simd";
src = cleanSourceWithRegexes cosmos-sdk-src [ ".*cosmovisor.*" ];
vendorSha256 = "sha256-kYoGoNT9W7x8iVjXyMCe72TCeq1RNILw53SmNpv/VXg=";
doCheck = false;
};
osmosis = pkgs.buildGoModule {
name = "osmosis";
src = osmosis-src;
vendorSha256 = "sha256-1z9XUOwglbi13w9XK87kQxLl4Hh+OcLZlXfw8QyVGZg=";
preCheck = ''
export HOME="$(mktemp -d)"
'';
};
iris = pkgs.buildGoModule {
name = "iris";
src = iris-src;
vendorSha256 = "sha256-PBbOuSe4GywD2WTgoZZ/1QDXH5BX2UHseXU2vPrJKX8=";
};
regen = pkgs.buildGoModule {
name = "regen";
subPackages = [ "app/regen" ];
src = regen-src;
vendorSha256 = "sha256-NH7flr8ExsfNm5JWpTGMmTRmcbhRjk9YYmqOnBRVmQM=";
preCheck = ''
export HOME="$(mktemp -d)"
'';
};
evmos = pkgs.buildGoModule {
name = "evmos";
src = evmos-src;
vendorSha256 = "sha256-c2MJL52achqlTbu87ZUKehnn92Wm6fTU/DIjadCUgH4=";
preCheck = ''
export HOME="$(mktemp -d)"
'';
};
relayer = pkgs.buildGoModule {
name = "relayer";
src = relayer-src;
vendorSha256 = "sha256-AelUjtgI9Oua++5TL/MEAAOgxZVxhOW2vEEhNdH3aBk=";
doCheck = false;
};

# Rust resources
hermes = naersk.lib."${system}".buildPackage {
pname = "ibc-rs";
root = ibc-rs-src;
buildInputs = with pkgs; [ rustc cargo pkgconfig ];
nativeBuildInputs = with pkgs; [ openssl ];
};
cosmovisor = (import ./resources/cosmovisor) {
inherit pkgs;
cosmovisor-src = "${cosmos-sdk-src}/cosmovisor";

# Misc
gm = with pkgs; (import ./resources/gm) {
inherit ibc-rs-src shellcheck lib makeWrapper gnused;
stoml = packages.stoml;
sconfig = packages.sconfig;
mkDerivation = stdenv.mkDerivation;
};
cosmos-sdk = (import ./resources/cosmos-sdk) { inherit pkgs cosmos-sdk-src; };
gaia6 = (import ./resources/gaia6) { inherit gaia6-src pkgs; };
gaia5 = (import ./resources/gaia5) { inherit gaia5-src pkgs; };
gaia4 = (import ./resources/gaia4) { inherit gaia4-src pkgs; };
osmosis = (import ./resources/osmosis) { inherit pkgs osmosis-src; };
iris = (import ./resources/iris) { inherit iris-src pkgs; };
regen = (import ./resources/regen) { inherit regen-src pkgs; };
evmos = (import ./resources/evmos) { inherit evmos-src pkgs; };
ts-relayer = ((import ./resources/ts-relayer) { inherit ts-relayer-src pkgs eval-pkgs; }).ts-relayer;
ts-relayer-setup = ((import ./resources/ts-relayer) { inherit ts-relayer-src pkgs eval-pkgs; }).ts-relayer-setup;
relayer = ((import ./resources/relayer) { inherit relayer-src pkgs; });
# thor = (import ./resources/thor) { inherit pkgs thor-src; };
# juno = (import ./resources/juno) { inherit juno-src pkgs; };
};

# Script helpers
go-source-inputs = (import ./sync-go-modules/go-source-inputs.nix) { inherit inputs; };
go-modules-sync = pkgs.writeShellScriptBin "syncGoModules" ''
echo "${go-source-inputs}" | ./sync-go-modules/sync.hs
'';
} // (import ./resources/gaia { inherit pkgs gaia4-src gaia5-src gaia6_0_2-src gaia6_0_3-src; });

# Dev shells
devShells = {
nix-shell =
pkgs.mkShell {
shellHook = self.checks.${system}.pre-commit-check.shellHook;
buildInputs = with pkgs; [
gomod2nix
go-modules-sync
rnix-lsp
];
};
Expand Down
11 changes: 0 additions & 11 deletions resources/cosmos-sdk/default.nix

This file was deleted.

Loading