forked from the-distro/ofborg
Use a patched carnix emission with a smarter include
This commit is contained in:
parent
5f9bc10a2d
commit
d466b9d3b7
50
nix/carnix.patch
Normal file
50
nix/carnix.patch
Normal file
|
@ -0,0 +1,50 @@
|
|||
diff --git a/nix/ofborg-carnix.nix b/nix/ofborg-carnix.nix
|
||||
index e974c8f..0094e27 100644
|
||||
--- a/nix/ofborg-carnix.nix
|
||||
+++ b/nix/ofborg-carnix.nix
|
||||
@@ -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:
|
|
@ -2,5 +2,13 @@
|
|||
|
||||
cd nix
|
||||
|
||||
carnix ./../ofborg/Cargo.lock --output ./ofborg-carnix.nix
|
||||
carnix ./../ircbot/Cargo.lock --output ./ircbot-carnix.nix
|
||||
patched_carnix() {
|
||||
src=$1
|
||||
result=$2
|
||||
|
||||
carnix "$src" --output "$result"
|
||||
patch -p1 "$result" ./carnix.patch
|
||||
}
|
||||
|
||||
patched_carnix ./../ofborg/Cargo.lock ./ofborg-carnix.nix
|
||||
patched_carnix ./../ircbot/Cargo.lock ./ircbot-carnix.nix
|
||||
|
|
Loading…
Reference in a new issue