nix: Use mkFilter in local status-go source

Signed-off-by: Pedro Pombeiro <pombeirp@users.noreply.github.com>
This commit is contained in:
Pedro Pombeiro 2019-11-25 10:17:28 +01:00
parent b32dd113f6
commit 7e6caf03ad
No known key found for this signature in database
GPG Key ID: C4A24185B2AA48A1
4 changed files with 34 additions and 21 deletions

View File

@ -2,10 +2,6 @@ source 'https://rubygems.org'
gem 'fastlane', '>= 2.131.0' gem 'fastlane', '>= 2.131.0'
plugins_path = ENV['FASTLANE_PLUGINFILE_PATH'] plugins_path = ENV['FASTLANE_PLUGINFILE_PATH'] ||
File.join(__dir__, 'Pluginfile')
if plugins_path == nil
plugins_path = File.join(__dir__, 'Pluginfile')
end
eval_gemfile(plugins_path) if plugins_path eval_gemfile(plugins_path) if plugins_path

View File

@ -22,7 +22,7 @@ let
buildGoPackage = pkgs.buildGoPackage.override { inherit go; }; buildGoPackage = pkgs.buildGoPackage.override { inherit go; };
desktop = pkgs.callPackage ./desktop { inherit target-os stdenv status-go pkgs go nodejs; inherit (pkgs) darwin; }; desktop = pkgs.callPackage ./desktop { inherit target-os stdenv status-go pkgs go nodejs; inherit (pkgs) darwin; };
mobile = pkgs.callPackage ./mobile { inherit target-os config stdenv pkgs mkShell nodejs yarn status-go maven localMavenRepoBuilder mkFilter; inherit (pkgs.xcodeenv) composeXcodeWrapper; }; mobile = pkgs.callPackage ./mobile { inherit target-os config stdenv pkgs mkShell nodejs yarn status-go maven localMavenRepoBuilder mkFilter; inherit (pkgs.xcodeenv) composeXcodeWrapper; };
status-go = pkgs.callPackage ./status-go { inherit target-os config go buildGoPackage; inherit (mobile.ios) xcodeWrapper; androidPkgs = mobile.android.androidComposition; }; status-go = pkgs.callPackage ./status-go { inherit target-os config go buildGoPackage mkFilter; inherit (mobile.ios) xcodeWrapper; androidPkgs = mobile.android.androidComposition; };
# mkFilter is a function that allows filtering a directory structure (used for filtering source files being captured in a closure) # mkFilter is a function that allows filtering a directory structure (used for filtering source files being captured in a closure)
mkFilter = import ./tools/mkFilter.nix { inherit (stdenv) lib; }; mkFilter = import ./tools/mkFilter.nix { inherit (stdenv) lib; };
localMavenRepoBuilder = localMavenRepoBuilder =

View File

@ -1,5 +1,5 @@
{ target-os, config, stdenv, callPackage, { target-os, config, stdenv, callPackage,
buildGoPackage, go, fetchFromGitHub, openjdk, buildGoPackage, go, fetchFromGitHub, mkFilter, openjdk,
androidPkgs, xcodeWrapper }: androidPkgs, xcodeWrapper }:
let let
@ -23,7 +23,20 @@ let
rev = "unknown"; rev = "unknown";
shortRev = "unknown"; shortRev = "unknown";
versionName = "develop"; versionName = "develop";
src = stdenv.lib.cleanSource "${traceValFn (path: "Using local ${repo} sources from ${path}\n") config.status_go.src_override}"; src =
let path = traceValFn (path: "Using local ${repo} sources from ${path}\n") config.status_go.src_override;
in builtins.path { # We use builtins.path so that we can name the resulting derivation, otherwise the name would be taken from the checkout directory, which is outside of our control
inherit path;
name = "${repo}-source-${shortRev}";
filter =
# Keep this filter as restrictive as possible in order to avoid unnecessary rebuilds and limit closure size
mkFilter {
dirRootsToInclude = [];
dirsToExclude = [ ".git" ".svn" "CVS" ".hg" ".vscode" ".dependabot" ".github" ".ethereumtest" "build" "eth-node" "protocol" ];
filesToInclude = [ "Makefile" "go.mod" "go.sum" "VERSION" ];
root = path;
};
};
} else } else
# Otherwise grab it from the location defined by status-go-version.json # Otherwise grab it from the location defined by status-go-version.json
let let

View File

@ -16,23 +16,27 @@ let
allowedPathElementsSubset = take count allowedPathElements; allowedPathElementsSubset = take count allowedPathElements;
in (compareLists compare allowedPathElementsSubset pathElementsSubset) == 0; in (compareLists compare allowedPathElementsSubset pathElementsSubset) == 0;
mkFilter = { dirRootsToInclude, # Relative paths of directories to include mkFilter = {
dirRootsToInclude, # Relative paths of directories to include
dirsToExclude ? [ ], # Base names of directories to exclude dirsToExclude ? [ ], # Base names of directories to exclude
filesToInclude ? [ ], # Relative path of files to include filesToInclude ? [ ], # Relative path of files to include
filesToExclude ? [ ], # Relative path of files to exclude filesToExclude ? [ ], # Relative path of files to exclude
root }: root }:
path: type:
let let
baseName = baseNameOf (toString path); allPathRootsAllowed = (length dirRootsToInclude) == 0;
subpath = elemAt (splitString "${toString root}/" path) 1; in
spdir = elemAt (splitString "/" subpath) 0; path: type:
let
baseName = baseNameOf (toString path);
subpath = elemAt (splitString "${toString root}/" path) 1;
spdir = elemAt (splitString "/" subpath) 0;
in lib.cleanSourceFilter path type && ( in lib.cleanSourceFilter path type && (
(type != "directory" && (elem spdir filesToInclude) && !(elem spdir filesToExclude)) || (type != "directory" && (elem spdir filesToInclude) && !(elem spdir filesToExclude)) ||
# check if any part of the directory path is described in dirRootsToInclude # check if any part of the directory path is described in dirRootsToInclude
((any (dirRootToInclude: isPathAllowed dirRootToInclude subpath) dirRootsToInclude) && ! ( ((allPathRootsAllowed || (any (dirRootToInclude: isPathAllowed dirRootToInclude subpath) dirRootsToInclude)) && ! (
# Filter out version control software files/directories # Filter out version control software files/directories
(type == "directory" && (elem baseName dirsToExclude)) (type == "directory" && (elem baseName dirsToExclude))
))); )));
in mkFilter in mkFilter