polkadot.nix is a collection of Nix packages related to the Polkadot ecosystem.
You need to enable flakes support.
You can use polkadot.nix as a standalone flake or integrate it into your existing nix flake project.
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"
{
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 ];
};
};
}
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;
};
}
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
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"
You can also integrate it into a flake and override it with more packages:
{
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.devShells.${system}.default.overrideAttrs (attrs: {
nativeBuildInputs = with pkgs; attrs.nativeBuildInputs ++ [ zombienet ];
});
};
}