Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ rls*.log
scripts/ci/node-template-release/Cargo.lock
bin/node-template/Cargo.lock
substrate.code-workspace
result
67 changes: 67 additions & 0 deletions flake.lock

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

83 changes: 83 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# nix run github:paritytech/substrate#subkey
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
let
per_system = flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
rust-native-build-inputs = with pkgs; [ clang pkg-config ];
rust-src = pkgs.lib.cleanSourceWith {
src = pkgs.lib.cleanSource ./.;
filter = pkgs.nix-gitignore.gitignoreFilterPure
(name: type:
(
(type == "regular" && pkgs.lib.strings.hasSuffix ".nix" name)
== false
&&
(type == "directory" && ".github" == name) == false
)
)
[ ./.gitignore ] ./.;
};
rust-env = with pkgs; {
LD_LIBRARY_PATH = pkgs.lib.strings.makeLibraryPath [
pkgs.stdenv.cc.cc.lib
pkgs.llvmPackages.libclang.lib
];
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
PROTOC = "${pkgs.protobuf}/bin/protoc";
ROCKSDB_LIB_DIR = "${pkgs.rocksdb}/lib";
};

darwin = pkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs.darwin.apple_sdk; [
frameworks.Security
]);

rust-libs = {
buildInputs = with pkgs; [ openssl ] ++ darwin;
nativeBuildInputs = rust-native-build-inputs;
doCheck = false;
};
rust-deps = pkgs.makeRustPlatform {
inherit pkgs;
cargo = pkgs.rust-bin.beta.latest.default;
rustc = pkgs.rust-bin.beta.latest.default;
Comment on lines +57 to +58
Copy link
Contributor

@andresilva andresilva May 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stable works as well, and we could even use the rust toolchain from nixpkgs directly (that's what I use to build subkey on my computer).

};
subkey = with pkgs; rust-deps.buildRustPackage (rust-libs // rust-env // rec {
name = "subkey";
src = rust-src;
cargoLock = {
lockFile = ./Cargo.lock;
};
doCheck = false;
cargoBuildFlags = "--package ${name}";
});

in
{
packages = {
inherit subkey;
};
}
);
in
per_system // {
overlays = final: prev: {
subkey = per_system.packages.${prev.system}.subkey;
};
};
}