Skip to content

andresilva/polkadot.nix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

357 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nix-polkadot logo

polkadot.nix is a collection of Nix packages related to the Polkadot ecosystem.

Packages

Usage

You need to enable flakes support.

You can use polkadot.nix as a standalone flake or integrate it into your existing nix flake project.

Running directly via nix run

nix run "github:andresilva/polkadot.nix#polkadot"

This will build and run the polkadot package from the flake. Check all available outputs with:

nix flake show "github:andresilva/polkadot.nix"

Integrate into existing flake

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    polkadot.url = "github:andresilva/polkadot.nix";
    polkadot.inputs.nixpkgs.follows = "nixpkgs";
  };
  outputs =
    { nixpkgs, polkadot, ... }:
    let
      system = "x86_64-linux";
    in
    {
      devShells.${system}.default = nixpkgs.legacyPackages.${system}.mkShell {
        buildInputs = [ polkadot.packages.${system}.polkadot ];
      };
    };
}

Overlay

You can use polkadot.nix as an overlay to seamlessly integrate all Polkadot packages into your existing nixpkgs environment.

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    polkadot.url = "github:andresilva/polkadot.nix";
    polkadot.inputs.nixpkgs.follows = "nixpkgs";
  };
  outputs =
    { nixpkgs, polkadot, ... }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs {
        inherit system;
        overlays = [ polkadot.overlays.default ];
      };
    in
    {
      packages.${system}.default = pkgs.polkadot;
    };
}

Cachix

Use Cachix to speed up builds by fetching pre-built binaries from a remote cache, reducing compilation times and improving overall efficiency.

cachix use polkadot

Development shell

A shell derivation is included that provides a development environment with all the requirements necessary to build polkadot-sdk.

You can run it directly with:

nix develop "github:andresilva/polkadot.nix"

The default shell uses the stable Rust toolchain, a nightly shell built from the latest toolchain is also available:

nix develop "github:andresilva/polkadot.nix#nightly"

Customizing the shell

The shell is also exposed as a builder function, lib.${system}.mkDevShell, so downstream flakes can pick a toolchain channel and linker, and add their own packages and environment variables:

Argument Default Description
channel "stable" Rust toolchain channel ("stable", "beta", or "latest" for nightly).
linker "wild" Linker used on Linux ("wild", "mold" or "lld"), ignored on Darwin, which always uses lld.
packages [ ] Extra packages, prepended so they take precedence on PATH.
env { } Extra environment variables, added to the defaults (overriding those with the same name).
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    polkadot.url = "github:andresilva/polkadot.nix";
    polkadot.inputs.nixpkgs.follows = "nixpkgs";
  };
  outputs =
    { nixpkgs, polkadot, ... }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs {
        inherit system;
        overlays = [ polkadot.overlays.default ];
      };
    in
    {
      devShells.${system}.default = polkadot.lib.${system}.mkDevShell {
        linker = "mold";
        packages = with pkgs; [ zepter ];
        env.RUSTC_WRAPPER = pkgs.lib.getExe pkgs.sccache;
      };
    };
}

About

Polkadot ecosystem nixified

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages