Use the patched carnix output for faster builds

This commit is contained in:
Graham Christensen 2018-02-08 15:18:21 -05:00
parent d466b9d3b7
commit c5fef482ec
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
4 changed files with 72 additions and 15 deletions

View file

@ -2,7 +2,7 @@
name = "ircbot"
version = "0.1.0"
authors = ["Graham Christensen <graham@grahamc.com>"]
include = [ "Cargo.lock", "Cargot.toml", "lib.rs", "src"]
[dependencies]
log = "0.3.8"
env_logger = "0.4.3"

View file

@ -2,12 +2,39 @@
{ lib, buildPlatform, buildRustCrate, fetchgit }:
let kernel = buildPlatform.parsed.kernel.name;
abi = buildPlatform.parsed.abi.name;
include = includedFiles: src: builtins.filterSource (path: type:
lib.lists.any (f:
let p = toString (src + ("/" + f)); in
(path == p) || (type == "directory" && lib.strings.hasPrefix path p)
) includedFiles
) src;
include = includedFiles: src:
# The comments assume the `include` field of the Cargo.toml like:
# include = [ "foo", "bar" ]
# and the package is being built from /mypackage
#
# includeFiles == [ "foo" "bar" ]
let
# and includedFileAbsolutePaths == [ "/mypackage/foo" "/mypackage/bar" ]
includedFileAbsolutePaths = builtins.map (relativePath: toString (src + ("/" + relativePath))) includedFiles;
# Return true only when a possible path exactly matches an
# absolute path, ie:
#
# checkExactMatch "/mypackage/foo" == true
# checkExactMatch "/mypackage/foo/bar" == false
# checkExactMatch "/mypackage/baz" == false
checkExactMatch = possiblePath: builtins.elem possiblePath includedFileAbsolutePaths;
# Return true only when a possible path is a suffix to a
# directory described by the include.
#
# checkPrefixMatch "/mypackage/buzfoo" == false
# checkPrefixMatch "/mypackage/foo" == false
# checkPrefixMatch "/mypackage/foo/bar" == true
# checkPrefixMatch "/mypackage/baz/foo" == false
checkPrefixMatch = possiblePath: lib.lists.any
(acceptablePrefix: lib.strings.hasPrefix "${acceptablePrefix}/" possiblePath)
includedFileAbsolutePaths;
in builtins.filterSource (possiblePath: _type:
builtins.trace "${possiblePath}" ((checkExactMatch possiblePath) || (checkPrefixMatch possiblePath))
)
src;
updateFeatures = f: up: functions: builtins.deepSeq f (lib.lists.foldl' (features: fun: fun features) (lib.attrsets.recursiveUpdate f up) functions);
mapFeatures = features: map (fun: fun { features = features; });
mkFeatures = feat: lib.lists.foldl (features: featureName:
@ -337,7 +364,7 @@ rec {
crateName = "ircbot";
version = "0.1.0";
authors = [ "Graham Christensen <graham@grahamc.com>" ];
src = ./../ircbot;
src = include [ "Cargo.lock" "Cargot.toml" "lib.rs" "src" ] ./../ircbot;
inherit dependencies buildDependencies features;
};
itoa_0_3_4_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate {

View file

@ -2,12 +2,39 @@
{ lib, buildPlatform, buildRustCrate, fetchgit }:
let kernel = buildPlatform.parsed.kernel.name;
abi = buildPlatform.parsed.abi.name;
include = includedFiles: src: builtins.filterSource (path: type:
lib.lists.any (f:
let p = toString (src + ("/" + f)); in
(path == p) || (type == "directory" && lib.strings.hasPrefix path p)
) includedFiles
) src;
include = includedFiles: src:
# The comments assume the `include` field of the Cargo.toml like:
# include = [ "foo", "bar" ]
# and the package is being built from /mypackage
#
# includeFiles == [ "foo" "bar" ]
let
# and includedFileAbsolutePaths == [ "/mypackage/foo" "/mypackage/bar" ]
includedFileAbsolutePaths = builtins.map (relativePath: toString (src + ("/" + relativePath))) includedFiles;
# Return true only when a possible path exactly matches an
# absolute path, ie:
#
# checkExactMatch "/mypackage/foo" == true
# checkExactMatch "/mypackage/foo/bar" == false
# checkExactMatch "/mypackage/baz" == false
checkExactMatch = possiblePath: builtins.elem possiblePath includedFileAbsolutePaths;
# Return true only when a possible path is a suffix to a
# directory described by the include.
#
# checkPrefixMatch "/mypackage/buzfoo" == false
# checkPrefixMatch "/mypackage/foo" == false
# checkPrefixMatch "/mypackage/foo/bar" == true
# checkPrefixMatch "/mypackage/baz/foo" == false
checkPrefixMatch = possiblePath: lib.lists.any
(acceptablePrefix: lib.strings.hasPrefix "${acceptablePrefix}/" possiblePath)
includedFileAbsolutePaths;
in builtins.filterSource (possiblePath: _type:
builtins.trace "${possiblePath}" ((checkExactMatch possiblePath) || (checkPrefixMatch possiblePath))
)
src;
updateFeatures = f: up: functions: builtins.deepSeq f (lib.lists.foldl' (features: fun: fun features) (lib.attrsets.recursiveUpdate f up) functions);
mapFeatures = features: map (fun: fun { features = features; });
mkFeatures = feat: lib.lists.foldl (features: featureName:
@ -383,7 +410,7 @@ rec {
crateName = "ofborg";
version = "0.1.1";
authors = [ "Graham Christensen <graham@grahamc.com>" ];
src = ./../ofborg;
src = include [ "Cargo.toml" "Cargo.lock" "src" "test-srcs" ] ./../ofborg;
inherit dependencies buildDependencies features;
};
openssl_0_9_23_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate {

View file

@ -2,6 +2,9 @@
name = "ofborg"
version = "0.1.1"
authors = ["Graham Christensen <graham@grahamc.com>"]
include = ["Cargo.toml", "Cargo.lock", "src", "test-srcs"]
[dependencies]
log = "= 0.3.8"