Skip to content

Commit

Permalink
feat: merge flake.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
DieracDelta committed Mar 7, 2022
1 parent 533efc4 commit bb65867
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 282 deletions.
18 changes: 9 additions & 9 deletions flake.lock

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

65 changes: 54 additions & 11 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
outputs = { self, nixpkgs, flake-compat, utils, crate2nix, fenix }:
utils.lib.eachDefaultSystem (system:
let
fenixPackage = fenix.packages.${system}.stable.withComponents [ "cargo" "clippy" "rust-src" "rustc" "rustfmt"];
fenixStable = fenix.packages.${system}.stable.withComponents [ "cargo" "clippy" "rust-src" "rustc" "rustfmt" ];
# needed for compiling static binary
fenixMusl = with fenix.packages.${system}; combine [ (stable.withComponents [ "cargo" "clippy" "rustc" "rustfmt" ]) targets.x86_64-unknown-linux-musl.stable.rust-std];
# needed to generate grcov graphs
fenixNightly = fenix.packages.${system}.latest.withComponents [ "cargo" "clippy" "rust-src" "rustc" "rustfmt" ];
rustOverlay = final: prev:
{
inherit fenixPackage;
rustc = fenixPackage;
cargo = fenixPackage;
rust-src = fenixPackage;
rustc = fenixStable;
cargo = fenixStable;
rust-src = fenixStable;
};

pkgs = import nixpkgs {
Expand Down Expand Up @@ -55,22 +58,62 @@
rootFeatures = [ "demo" "docs" "blake3" "threshold_crypto/use-insecure-test-only-mock-crypto" ] ;
defaultCrateOverrides = pkgs.defaultCrateOverrides // {
# Crate dependency overrides go here
# pass in protobuf
prost-build = attrs: {
buildInputs = [ pkgs.protobuf ];
PROTOC = "${pkgs.protobuf}/bin/protoc";
PROTOC_INCLUDE = "${pkgs.protobuf}/include";
};
libp2p-core = attrs: {
buildInputs = [ pkgs.protobuf ];
PROTOC = "${pkgs.protobuf}/bin/protoc";
PROTOC_INCLUDE = "${pkgs.protobuf}/include";
};
};
};


pkgsAndChecksList = pkgs.lib.mapAttrsToList (name: val: { packages.${name} = val.build; checks.${name} = val.build.override { runTests = true; }; }) project.workspaceMembers;
# programatically generate output packages based on what exists in the workspace
pkgsAndChecksAttrSet = pkgs.lib.foldAttrs (n: a: pkgs.lib.recursiveUpdate n a) {} pkgsAndChecksList;

buildDeps = with pkgs; [
cargo-audit nixpkgs-fmt git-chglog protobuf fenix.packages.${system}.rust-analyzer
] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security pkgs.libiconv darwin.apple_sdk.frameworks.SystemConfiguration];

in
pkgsAndChecksAttrSet //
{
packages.${crateName} = project.workspaceMembers.phaselock.build;
checks.${crateName} = project.workspaceMembers.phaselock.build.override {
runTests = true;
};

defaultPackage = self.packages.${system}.${crateName};

devShell = pkgs.mkShell {
inputsFrom = builtins.attrValues self.packages.${system};
buildInputs =
with pkgs; [ cargo-audit nixpkgs-fmt git-chglog fenix.packages.${system}.rust-analyzer fenixPackage ];
with pkgs; [ fenixStable ] ++ buildDeps;
};

devShells = {
# usage: compile a statically linked musl binary
staticShell = pkgs.mkShell {
shellHook = ''
ulimit -n 1024
export RUSTFLAGS='-C target-feature=+crt-static'
export CARGO_BUILD_TARGET='x86_64-unknown-linux-musl'
'';
buildInputs =
with pkgs; [ fenixMusl ] ++ buildDeps;
};

# usage: evaluate performance (grcov + flamegraph)
perfShell = pkgs.mkShell {
buildInputs = with pkgs; [ grcov flamegraph fd fenixNightly ] ++ buildDeps;
shellHook = ''
ulimit -n 1024
export RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
export RUSTDOCFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
export CARGO_INCREMENTAL=0
'';
};
};
});
}
117 changes: 0 additions & 117 deletions libp2p-networking/flake.lock

This file was deleted.

145 changes: 0 additions & 145 deletions libp2p-networking/flake.nix

This file was deleted.

0 comments on commit bb65867

Please sign in to comment.