Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/informalsystems/cosmos.nix
A reproducible package set for Cosmos, IBC and CosmWasm
https://github.com/informalsystems/cosmos.nix
Last synced: 3 months ago
JSON representation
A reproducible package set for Cosmos, IBC and CosmWasm
- Host: GitHub
- URL: https://github.com/informalsystems/cosmos.nix
- Owner: informalsystems
- License: mit
- Created: 2021-07-14T12:24:45.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-09T12:38:55.000Z (7 months ago)
- Last Synced: 2024-04-14T07:35:39.340Z (7 months ago)
- Language: Nix
- Homepage: https://flakehub.com/flake/informalsystems/cosmos.nix
- Size: 1020 KB
- Stars: 48
- Watchers: 18
- Forks: 10
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-cosmos - cosmos.nix - [Nix](https://nixos.org/) support for Cosmos and CosmWasm. (Tools / CLI)
README
# Cosmos.nix
This is an experimental Nix project for integrating the Rust and Go projects in Cosmos
as Nix packages. Use this at your own risk.## Setup
NOTE: If you already have nix installed, make sure you are on version >=2.18.
Instructions to upgrade nix can be found [here](https://nixos.org/manual/nix/unstable/installation/upgrading.html)### Non-NixOS
This project is developed entirely in [Nix Flakes](https://nixos.wiki/wiki/Flakes).
To get started, run the following:1. [Install Nix](https://nixos.org/download.html):
```bash
$ curl -L https://nixos.org/nix/install | sh
```2. [Install Nix Unstable](https://serokell.io/blog/practical-nix-flakes):
```bash
$ nix-env -iA nixpkgs.nixFlakes
```3. [Enable experimental features](https://serokell.io/blog/practical-nix-flakes):
```bash
mkdir -p ~/.config/nix
echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf
```4. [Setup Caches](https://nixos.org/manual/nix/unstable/package-management/sharing-packages.html):
Run this to add the `cosmos-nix` cache as a substituter
```bash
cachix use cosmos-nix
```## Shell
If you are just here for a remote nix shell (a development environment where
you don't need to clone the repo) you can run the following command:```bash
nix develop github:informalsystems/cosmos.nix#cosmos-shell
```This will build the development environment. The environment will then be
cached in your nix store and should be very fast. If you want to pull the
latest development environment you should run:```bash
nix develop github:informalsystems/cosmos.nix#cosmos-shell --refresh
```## Overlays
There are a few nix utilities provided as a nix library. There is also an
overlay for all the cosmos packages exported by this flake, so you can fold
them into your nixpkgs package set.```nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
cosmos-nix.url = "github:informalsystems/cosmos.nix";
};
outputs = { cosmos-nix, nixpkgs }: {
let pkgs = import nixpkgs {
system = "x86_64-linux"; # Or whatever system you are on
overlays = [
cosmos-nix.overlays.cosmosNixLib # Provides just the nix utility lib
cosmos-nix.overlays.cosmosNixPackages # Provides all the cosmos packages provided by cosmos.nix
cosmos-nix.overlay # The default overlay gives you everything in the previous two combined
];
}
in ...
};
}
```## Development
#### Formatting
Formatting will be run via the default nix command. You can find the formatter configuration in `modules/formatter.nix`
```bash
nix fmt
```#### Contribution Guide
1. Add the chains source code as a flake input
```nix
inputs = {
my-chain-src.url = "github:my-chains-organization/my-chains-repo";
my-chain-src.flake = false;
};
```2. Add a new file in `packages/` named after the chain that you are packaging
> Usually you will use this structure for cosmos-sdk chains, there are other examples of non-sdk chains in the repo
```nix
# packages/my-chain.nix
{
mkCosmosGoApp,
my-chain-src,
}:
mkCosmosGoApp {
name = "my-chain";
version = "v0.1.0";
src = my-chain-src;
rev = my-chain-src.rev;
vendorHash = "sha256-WLLQKXjPRhK19oEdqp2UBZpi9W7wtYjJMj07omH41K0=";
tags = ["netgo"];
engine = "cometbft/cometbft";
}
```3. Import your new derivation into the `modules/packages.nix` file
```nix
my-chain = import ../packages/my-chain.nix {
inherit (cosmosLib) mkCosmosGoApp;
inherit (inputs) my-chain-src;
};
```4. Test that it works by running:
```
> git add .
> nix build .#my-chain
```5. Add the package to apps.nix, after you have built the package in step 4 you can check what the binary path is by running `ls result/`
```nix
my-chain = {
type = "app";
program = "${packages.my-chain}/bin/mychaind";
};
```